EOF

Hi,
I want to make a program in C which let you write something while the imput is != EOF.
I think is:
-ask you the text
-save it in a string (because then i have to work on it)
-check if there is EOF

I tried:

1
2
3
4
  while ((i < N) && ((c = getchar()) != EOF))
        {
    str1[i++] =c;
    } 


And yeah it "works"... but if i enter a text like:

-I have two or^Zanges

it wont stop, enter a loop. Stops only if I enter ^Z as the first character of a nw line...

How can I make it work???

Thx



Topic archived. No new replies allowed.