In the K&R, chapter 8, it has a custom implementation of the putc and getc functions. In the first definition of getc, if the parameter is stdin, according to the definition of _iob, the function will try to write in the address 0 because this is the value which _iob[0].ptr and _iob[0].base were assigned. Is this legal?
Code: http://ideone.com/AIkCA
Definition of _iob:
FILE _iob[20] = {
{0, (char *) 0, (char *) 0, _READ, 0},
{0, (char *) 0, (char *) 0, _WRITE, 0},
{0, (char *) 0, (char *) 0, _WRITE, 0}
};