Pass an EOF instead of pressing enter
- From: "Camellia" <breakfastea@xxxxxxxxx>
- Date: 30 Dec 2006 20:27:39 -0800
Hi all,
I'll get straight into it.
When I try to run the code:
.....
while (scanf("%c", &c) == 1)
printf("%c", c);
.....
I input "abcd" follows by an EOF(Ctrl + d) instead of pressing enter,
and the program prints "abcd" on the screen. And then I pass an EOF
signal the program ends.
My question is why doesn't the program end the first it encounters the
EOF after the "abcd"?
And also if I DO press enter after "abcd", do I pass the characters
'a', 'b', 'c', 'd', '\n' to the program?
Any suggestions are appreciated.
.
- Follow-Ups:
- Re: Pass an EOF instead of pressing enter
- From: Richard Tobin
- Re: Pass an EOF instead of pressing enter
- Prev by Date: Pass an EOF before pressing enter
- Next by Date: Re: without loop printing 1 to n
- Previous by thread: Pass an EOF before pressing enter
- Next by thread: Re: Pass an EOF instead of pressing enter
- Index(es):
Relevant Pages
|