How to properly using EOF?
How to properly using EOF? I have question about EOF. First of all, I am coding a simple program that is coping/printing the user's input. However, the program copies the EOF also in the output. For an example, my O.S is Window and my EOF works when I type (Enter -> cntrl + z -> Enter) in order. If I input "Hello" + Enter + EOF key combination, the output prints the weird letter('?') at the end of the copied user input. How can I get rid of the '?' at the end of the output, and why is it happening? #include <stdio.h> void copy(char to, char from); main() { int i; int c; char origin[10]; char copied[10]; for(i = 0; (c = getchar()) != EOF; ++i) { origin[i] = c; } copy(copied, origin); for(i = 0; i < 10; i++) putchar(copied[i]); } void copy(char to, char from) { int i; i = 0; while((to[i] = from[i]) != '') i++; } Not the problem, but you ...