On Wed, 14 Nov 2007 06:01:22 -0800, "lovecreatesbea...@gmail.com"
<lo***************@gmail.comwrote:
>Thank you for your time.
#include <stdio.h>
int main(void)
{
int c;
while ((c = getchar()) != EOF){
putchar(c);
fflush(stdout);
}
return 0;
}
/* [a console interact session]
aaa^Zbbb [INPUT surrounding ^Z followed by enter]
[a single enter here]
aaa [output]
^Z [here, ^Z followed by an enter]
*/
Firstly, EOF is not a character at all. It is a special value
returned by some input functions to indicate the end-of-file condition
has been detected on the input stream.
Secondly, ^Z does not, by itself, cause this condition. It is a
convention used by some systems to allow a stream to simulate this
condition. But the convention may have restrictions. It is possible
your system has the restriction that ^Z will only serve this purpose
if it immediately follows an ENTER.
If you really want to know what is happening, you should print c as an
integer (I prefer hex) rather than a character. This way, you will
see exactly what characters getchar obtains. You might want to change
the while to a do-while so you see the EOF value also. (Currently you
may not be able to tell the difference between entering a ^Z and
entering a ^C.)
Remove del for email