2 ms·
In the beginning, there was the int. In K&R C, before function prototypes, all functions returned "int". ("float" and "double" were kludged in, without checking
by Animats 7y ago
In the beginning, there was the int. In K&R C, before function prototypes, all functions returned "int". ("float" and "double" were kludged in, without checking, at some point.)
So the character I/O functions returned a 16-bit signed int. There was no way to return a byte, or a "char". That allowed room for out of band signals such as EOF.
It's an artifact of that era. Along with "BREAK", which isn't a character either.
- bhaak 7y agoYou can still today declare a function without a return value like this: "a() { return 1; }". GCC only outputs a warning by default: "warning: return type defaults to ‘int’ [-Wimplicit-int]"