Re: Pass an EOF before pressing enter
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Sun, 31 Dec 2006 00:18:38 -0500
Camellia wrote:
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"?
Because you may really want to input a ^d it is only an EOF signal
when presented at the beginning of a line. You probably had to hit
ENTER (or return) after the first ^d.
And also if I DO press enter after "abcd", do I pass the characters
'a', 'b', 'c', 'd', '\n' to the program?
Yes.
--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
.
- References:
- Pass an EOF before pressing enter
- From: Camellia
- Pass an EOF before pressing enter
- Prev by Date: Re: comparing doubles for equality
- Next by Date: Re: without loop printing 1 to n
- Previous by thread: Pass an EOF before pressing enter
- Next by thread: Pass an EOF instead of pressing enter
- Index(es):