Reputation: 3165
while reading from k&r i came across the following example
#include<stdio.h>
int main()
{
int c;
while((c=getchar())!=EOF)
{
putchar(c);
}
printf("hello");
}
doubt 1:when i am typing the character ctrl+z(EOF on my sys) . o/p is hello
but when i am typing the string of characters like abcdef^Zghijk
o/p is abcdef->(including the arrow) and waiting for user to enter i/p instead of terminating loop and print hello..
Upvotes: 5
Views: 517
Reputation: 10142
ctrl+z
is not EOF, it is just a way to tell your terminal to close the stream.
On Windows systems you need to write the ctrl+z
as the first character of the line, otherwise the terminal considers it to be an ordinary character.
Upvotes: 5