Hacker News new | ask | show | jobs
by Animats 2283 days 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.

1 comments

You 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]"