0
Please explain the output...
Please Explain me ! main() { int c; while (( c = getchar() ) != EOF ) putchar(c); } My Expected result : i/p : abc o/p : a Computer result: i/p : abc o/p : abc ● If getchar() reads single character then why it is giving multiple characters ???
2 ответов
+ 3
Because you use it in a while loop until the end of file is reached.
So you get and print the chars one by one, but in the final output they appear glued together.
You could add a print statement that prints a space or new line, then you see, that it is done for one letter by another
+ 1
i advise not using get/putchar(), they're both pretty out of standard