question about getchar()

Jan 6, 2012 at 6:28pm
hi
maybe someone can help me
i want to use while loop until EOF to get characters
but in the same time to find if there is sequence like "word" in the text that entered
while(c=getchar() != EOF)
{

how can i find the sequence of characters?
Jan 6, 2012 at 8:17pm
You could use getline( file, input, '\n' );.

Save to a string and then do a check on it.
1
2
if( input == "word" )
   /* code */


'\n' is a newline character.
Jan 6, 2012 at 9:34pm
ok i will try your advice

i have a test this sunday and i try to solve some exrecises hope i secceed

thank you !!
Jan 6, 2012 at 9:37pm
did you mean to c language not c++ right?
Jan 6, 2012 at 9:39pm
It looks like C++ to me.
Jan 6, 2012 at 9:53pm
Ahh sorry, that was c++. Being a c++ forum and all... lol
Topic archived. No new replies allowed.