-
thank you Quzah. but, can you explain what stdin and ungetc? Upto this chapter, i haven't seen ungetc. I have just seen getc, getcha.
And, suppose, the user enter following line in the prompt:
am testing eieseisie michael eissen, the footballer#
Does the line upto # will be in buffer and read one by one by first getchar() and pass to char ch ?
-
stdin is the standard input stream. It's commonly the input from your keyboard.
stdout is the standard output stream, commonly you see this output on your monitor.
You can scatter a few printf statements around in the loop to get a better understanding of it. All it does is read one character at a time over and over from the input stream, then compares it.
ungetc will let you replace the last character you've read back onto the input stream, provided you've kept track of it. You must unget the same character you just pulled off of it, and you can't call it multiple times to unget more than one character. It only does one.
Quzah.