Why printf returns int in C?
Shouldn't there be type size_t instead?
It could have been, but of course, an early design decision was to place the return value of the negative EOF to indicate an error.
size_t was a bit late in the early design options. Many functions used by int , where size_t used now on those pre-standard days.
fprintf() has an environmental limit of "The number of characters that can be obtained with any single conversion must be at least 4095.", so any print that tries to get a long output may encounter this limit before the INT_MAX/SIZE_MAX .
source share