W
Walter Roberson
(e-mail address removed)-cnrc.gc.ca (Walter Roberson) wrote:
Why? Would you normally do
int i='\0';
rather than
char c='\0';
int i=0;
void *p=NULL;
Someone might (but *I* probably wouldn't), if i represented a character.
For example,
int i='\0';
if (somecondition) {
i = getchar();
}
if (i == EOF) {
/* whatever */
}
That is, Best Practice is to use an int to store any value that
is a char that has to be read in by getchar(), getc() or fgetc()
(because you need to be able to post-check against the int value EOF).
If someone were initializing that int and they wanted to emphasize the
char-in-int's-clothing nature of the variable, they just might
choose to initialize with '\0'... or might get confused about the
meaning of NULL and try to initialize with that.