// Andrew Taylor - andrewt@unsw.edu.au // 08/06/2020 #include int main(void) { char c; // c should be declared int //-1 while ((c = getchar()) != EOF) { //-1 putchar(c); } // Typically `stdio.h` contains: // ```c // #define EOF -1 // ``` // // - most platforms: char is signed (-128..127) // - loop will incorrectly exit for a byte containing 0xFF // echo -n -e '\x69 \x70 \xFF \xF0' | // //printf("%#hhx\n",c); // - rare platforms: char is unsigned (0..255) // - loop will never exit return 0; }