I want to terminate my input by input, EOF(^Z in windows), and here is the program:
#include<stdio.h>
#include<conio.h>
int main(void)
{
int c;
while ((c = getchar()) != EOF)
{
if (c == '\t')
{
putchar('\\');
putchar('t');
}
else if (c == '\b')
{
putchar('\\');
putchar('b');
}
else if (c == '\\')
{
putchar('\\');
putchar('\\');
}
else if (c == '\r')
{
puts("\\n");
// putchar('\n');
}
else{
putchar(c);
}
}
return 0;
}
and here is my input and output:
So I am asking: why can't I terminate my input by the first ^Z? Otherwise stated, why do I have to type enter to make a new line in order to terminate my input by input at ^Z?