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..
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With