Talk:cpp/io/c/fputc
From cppreference.com
The entry doesn't make clear what the difference between fputc() and putc() is. Could anyone add a clarification? 85.18.102.222 07:21, 29 June 2017 (PDT)
- I think it's already fairly clear: the page says "In C, putc() may be implemented as a macro, which is disallowed in C++. Therefore calls to std::fputc() and std::putc() always have the same effect." --Cubbi (talk) 08:19, 4 July 2017 (PDT)
[edit] What is returned?
About "On success, returns the written character", does it return an unsigned char? Or a char? This makes a difference because the former means we can assume that the int returned is >= 0. 85.18.102.222 07:25, 29 June 2017 (PDT)
- It returns an
int, as shown, and the standard only says "returns the character written" and POSIX says it returns "the value it has written". I think it implies the value returned is non-negative, but to be perfectly formally correct, you can't assume that: the intent is to compare the result with EOF and convert to char if it's not EOF. --Cubbi (talk) 08:19, 4 July 2017 (PDT)