From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3241 invoked by alias); 26 Dec 2013 19:51:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3228 invoked by uid 48); 26 Dec 2013 19:51:00 -0000 From: "Denis.V.Kolesnik@safe-mail.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59598] very simple code using file open for read Date: Thu, 26 Dec 2013 19:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.6.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: blocker X-Bugzilla-Who: Denis.V.Kolesnik@safe-mail.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg02213.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59598 Denis Kolesnik changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #6 from Denis Kolesnik --- please tell me where in this corrected code I made mistake:> // a small text file filter.c // #include main(int argc, char* argv[]) { char c, previous_c; int word_begin_position[3000]; int spec_symbol[7]={0xAE,0xBB,0xAB,0xA9,0x22,0x2F,0x27}; int eof_symbol[2]={0x0D,0x0A}; int search_result; int this_is_the_same_word; int words_count; int word_number; int search_result_A_count; int search_result_space; FILE *stream,*stream2; int i, j, characters_count, character_number; characters_count=0; stream = fopen (argv[1],"r"); while ((c = fgetc(stream)) != EOF) { characters_count++; } fclose(stream); //printf("total characters are %i\n", characters_count); character_number=1; words_count=0; previous_c=0; stream = fopen (argv[1],"r"); while ((c = fgetc(stream)) != EOF) { if(((c!=0x20) && (character_number==1)) || ((previous_c==0x20) && (c!=0x20) && (c!=0x0A)) || ((previous_c!=0x20) && (c==0x0D)) || ((c!=0x20) && (c!=0x0D) && (c!=0x0A) && (previous_c==0x0A)) || ((previous_c!=0x20) && (previous_c!=0x0A) && (character_number==characters_count) && (c==0x20))) // 1. ((c!=0x20) && (character_number==1)) // 2. ((previous_c==0x20) && (c!=0x20) && (c!=0x0A)) // 3. ((previous_c!=0x20) && (c==0x0D)) // !((previous_c!=0x0D) && (c==0x0A)) // 4. ((c!=0x20) && (c!=0x0D) && (c!=0x0A) && (previous_c==0x0A)) // 5. ((previous_c!=0x20) && (previous_c!=0x0A) && (character_number==characters_count) && (c==0x20)) this_is_the_same_word=0; else this_is_the_same_word=1; if(this_is_the_same_word==0) { words_count++; word_begin_position[words_count]=character_number; //printf(" the begin char is ..... %i",word_begin_position[words_count]); } //if(character_number==characters_count) // printf("the last character"); /* printf(" the number of words is %i\n", words_count); printf(" the current character is ..... %c\n", c); if(c==0x0D) printf(" the current character is ..... 0x0D\n"); if(c==0x0A) printf(" the current character is ..... 0x0A\n"); */ previous_c=c; character_number++; } fclose(stream); word_number=1; character_number=1; stream = fopen (argv[1],"r"); //stream2 = fopen (argv[2],"w"); while ((c = fgetc(stream)) != EOF) { //if((character_number >= word_begin_position[word_number]) && (character_number <= word_begin_position[word_number+1])) if(c==0x0D) then { //fprintf(stream2,"%s", "\\r\\n"); // if(c==EOF) // then // printf("A"); // else // printf("%s",c); printf("%s", c); } // else // word_number++; character_number++; } fclose(stream); //printf(" the number of words is %i", words_count); return 0; } why this portion of code:> if(c==0x0D) then { //fprintf(stream2,"%s", "\\r\\n"); // if(c==EOF) // then // printf("A"); // else // printf("%s",c); printf("%s", c); } // else // word_number++; reports:> replace_1.c: In function 'main': replace_1.c:112:3: error: 'then' undeclared (first use in this function) replace_1.c:112:3: note: each undeclared identifier is reported only once for ea ch function it appears in replace_1.c:113:3: error: expected ';' before '{' token