I am writing little program for encoding characters and I have a problem with reading NUL characters maybe also with another ones. My problem is that getchar in this code somehow ignores the NUL characters entered by CTRL + @ .
while ((numberOfRead < 40) && (character = getchar()) && (character != EOF) && (character != '\n')) { ... }
But this code works correctly and reads the NUL characters properly.
character = getchar();
while ((numberOfRead < 40) && (character != EOF) && (character != '\n')) {
numberOfChars++;
...
character = getchar();
}
What is the difference causing the problem? Thanks for any explanation of this behaviour. Code was tested on Windows 8.1, under gcc 4.7.1