I have this code:
Unfortunately, it's printing out an endless number of blank lines at the end, forever.Code:char c; int read1 = read(fd, &c, 1); while ( c != EOF ) { write(1, &c, 1); read1 = read(fd, &c, 1); }
I *think* it's because of this:
EOF = -1, and its size is 4 bytesCode:printf("EOF: %d, %d\n", EOF, sizeof(EOF));
So, since it's only reading 1 byte at a time, it never gets an EOF. (I *think*)
Am I doing something wrong? Is there a way to make this work?