Hello,
My question is this " getchar() returns a null value when it detects an EOF mark, right or wrong? WHY?
Hello,
My question is this " getchar() returns a null value when it detects an EOF mark, right or wrong? WHY?
"Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
-Bruce Lee
Straight from the manual
The value of EOF is (normally) -1.The getchar() function returns the next character from the input stream pointed to by stdin. If the stream is at end-of-file, the end-of-file indicator is set, and getchar() returns EOF. If a read error occurs, the error indicator is set, and getchar() returns EOF. When an error has occurred, errno contains a value that indicates the type of error that has been detected.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
No. They return EOF if they detect EOF. EOF is going to be outside the range of normal characters. IIRC, it will always fall outside the range of whatever you are trying to read. It is a unique value that specificly denotes EOF.
getchar
[edit]Hammer beat me to it.[/edit]
Quzah.
Hope is the first step on the road to disappointment.