public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Denis.V.Kolesnik@safe-mail.net" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-59598-4-FDBHG7aI1w@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59598-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59598

Denis Kolesnik <Denis.V.Kolesnik@safe-mail.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #6 from Denis Kolesnik <Denis.V.Kolesnik@safe-mail.net> ---
please tell me where in this corrected code I made mistake:>



// a small text file filter.c //

#include <stdio.h>



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


  parent reply	other threads:[~2013-12-26 19:51 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-25 16:56 [Bug c++/59598] New: " lirex.software at gmail dot com
2013-12-25 16:57 ` [Bug c++/59598] " lirex.software at gmail dot com
2013-12-25 16:59 ` lirex.software at gmail dot com
2013-12-25 17:08 ` pinskia at gcc dot gnu.org
2013-12-25 17:12 ` Denis.V.Kolesnik@safe-mail.net
2013-12-26 19:51 ` Denis.V.Kolesnik@safe-mail.net [this message]
2013-12-26 19:57 ` Denis.V.Kolesnik@safe-mail.net
2013-12-26 19:58 ` Denis.V.Kolesnik@safe-mail.net
2013-12-26 19:58 ` Denis.V.Kolesnik@safe-mail.net
2013-12-26 19:59 ` Denis.V.Kolesnik@safe-mail.net
2013-12-26 20:11 ` Denis.V.Kolesnik@safe-mail.net
2013-12-26 20:32 ` pinskia at gcc dot gnu.org
2013-12-26 20:34 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 15:07 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 17:01 ` schwab@linux-m68k.org
2013-12-28 17:18 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 19:31 ` pinskia at gcc dot gnu.org
2013-12-28 21:56 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 21:58 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 22:00 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 22:03 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 22:55 ` ktietz at gcc dot gnu.org
2013-12-28 22:59 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 23:01 ` ktietz at gcc dot gnu.org
2013-12-28 23:02 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 23:07 ` ktietz at gcc dot gnu.org
2013-12-28 23:12 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 23:13 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 23:17 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 23:18 ` Denis.V.Kolesnik@safe-mail.net
2013-12-28 23:25 ` ktietz at gcc dot gnu.org
2013-12-29 12:59 ` Denis.V.Kolesnik@safe-mail.net
2014-01-28 17:45 ` Denis.V.Kolesnik@safe-mail.net
2014-02-03 15:27 ` Denis.V.Kolesnik@safe-mail.net
2014-02-04  8:27 ` redi at gcc dot gnu.org
2014-02-08 17:02 ` Denis.V.Kolesnik@safe-mail.net
2014-02-08 17:05 ` Denis.V.Kolesnik@safe-mail.net
2014-02-08 17:19 ` Denis.V.Kolesnik@safe-mail.net
2014-02-08 17:46 ` schwab@linux-m68k.org
2014-02-08 18:09 ` Denis.V.Kolesnik@safe-mail.net
2014-02-08 18:09 ` Denis.V.Kolesnik@safe-mail.net
2014-02-08 18:11 ` Denis.V.Kolesnik@safe-mail.net
2014-02-08 18:59 ` redi at gcc dot gnu.org
2014-02-09 13:20 ` Denis.V.Kolesnik@safe-mail.net
2014-02-09 13:28 ` Denis.V.Kolesnik@safe-mail.net
2014-02-09 13:35 ` Denis.V.Kolesnik@safe-mail.net
2014-02-09 13:36 ` Denis.V.Kolesnik@safe-mail.net
2014-02-09 13:37 ` Denis.V.Kolesnik@safe-mail.net
2014-02-09 13:38 ` Denis.V.Kolesnik@safe-mail.net
2014-02-10 22:36 ` Denis.V.Kolesnik@safe-mail.net
2014-02-10 22:48 ` pinskia at gcc dot gnu.org
2014-02-10 23:12 ` Denis.V.Kolesnik@safe-mail.net
2014-02-10 23:14 ` Denis.V.Kolesnik@safe-mail.net
2014-02-10 23:30 ` pinskia at gcc dot gnu.org
2014-02-26 19:51 ` Denis.V.Kolesnik@safe-mail.net
2014-02-26 20:38 ` [Bug spam/59598] " redi at gcc dot gnu.org
2014-02-28  0:56 ` Denis.V.Kolesnik@safe-mail.net
2014-02-28  1:24 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-59598-4-FDBHG7aI1w@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).