3 ms·
> puts(3) only returns "a nonnegative integer on success and EOF on error" How does it decide which nonnegative integer to return?
by qwerty456127 5y ago
> puts(3) only returns "a nonnegative integer on success and EOF on error"
How does it decide which nonnegative integer to return?
- robotresearcher 5y agoIt's arbitrary. The article shows an implementation that returns 10 (ASCII '\n'). But the spec says it doesn't matter, so you should only be using it to test >0 for success.
- woodruffw 5y agoThat's answered below: > On success, puts(3) appears to return '\n', the newline or line feed (LF) character, which has ASCII value... 10. But note that that isn't standard behavior. The language in POSIX[1] is identical to that in the blog post. `puts` is free to return whatever positive number it wants on return. [1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/puts.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/p...