--------------------------------------------- $ pico copy1.c #include /* copy1.c - copy input to output, version 1 */ main() { int c; c = getchar(); while (c != EOF) { putchar(c); c = getchar(); } } ^X $ gcc copy1.c $ ls a.out copy1.c $ a.out AAAAA AAAAA ^D $ ./a.out < copy1.c > anothercopy.c $ ./a.out < a.out > copy ls a.out copy copy1.c anothercopy.c $ ./copy < anothercopy.c > yetanothercopy.c bash: ./copy: Permission denied % chmod 770 copy $ ./copy < anothercopy.c > yetanothercopy.c $ ls a.out copy copy1.c anothercopy.c yetanothercopy.c ------------------------------------------- 1. getchar() inputs a character (8-bit byte) and putchar() outputs a character. 2. getchar returns a 16-bit (or larger) int so that we can differentiate between an input byte of all 1's (0000000011111111) and the End Of File (1111111111111111). 3. Control D (^D) is keyboard EOF. 4. EOF (along with getchar and putchar) defined in . -------------------------------------------