Chapter 8 of K & R has a custom implementation of putc and getc functions. In the first definition of getc, if the stdin parameter, as defined by _iob, the function tries to write to address 0, because it is the value that _iob [0] .ptr and _iob [0] .base were assigned. Is it legal?
Code: http://ideone.com/AIkCA
_Iob definition:
FILE _iob[20] = {
{0, (char *) 0, (char *) 0, _READ, 0},
{0, (char *) 0, (char *) 0, _WRITE, 0},
{0, (char *) 0, (char *) 0, _WRITE, 0}
};
source
share