Pass an EOF before pressing enter



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.

.



Relevant Pages

  • Pass an EOF instead of pressing enter
    ... I'll get straight into it. ... I input "abcd" follows by an EOFinstead of pressing enter, ... And then I pass an EOF ... And also if I DO press enter after "abcd", do I pass the characters ...
    (comp.lang.c)
  • Re: Pass an EOF instead of pressing enter
    ... and the program prints "abcd" on the screen. ... And then I pass an EOF ... Pressing EOF without a newline ...
    (comp.lang.c)
  • Re: Pass an EOF before pressing enter
    ... I input "abcd" follows by an EOFinstead of pressing ... And also if I DO press enter after "abcd", do I pass the characters ... Chuck F (cbfalconer at maineline dot net) ... characters, and then enter button, it prints characters I just entered, ...
    (comp.lang.c)
  • Re: newbie I/O problem
    ... a sequence of characters for delimiters rather than a set of characters. ...
    (comp.lang.java.help)
  • Re: How does the complement work with transliteration ?
    ... > to mean- if its anything other than abcd replace with ... ... > b c and d found, with their corresponding replacement characters. ... give results that depend on what order the complement characters ...
    (comp.lang.perl.misc)