in c printf() returns what?
It returns the number of characters printed. See man fprintf
for simple questions like this.
From the man page:
These functions return the number of characters printed (not including the trailing '\0' used to end output to strings) or a negative value if an output error occurs, except for snprintf() and vsnprintf(), which return the number of characters that would have been printed if the n were unlimited (again, not including the final '\0').
printf
returns:
- On success, the total number of characters written.
- On failure, a negative number.
Number of characters (not including the trailing \0) printed on success, negative value on failure. see man printf.
The result of "printf" is the number of characters written. If a write error occurs, "printf" returns a negative number. (ANSI standard)
Even wikipedia has a whole article about printf, where you can find the different return values for different languages and times.
Exactly what it says it returns in any decent library reference
On success, the total number of characters written is returned. On failure, a negative number is returned.
- Point your browser to www.google.com;
- Search "printf c";
- Almost any result you'll get will tell you:
Return Value
On success, the total number of characters written is returned.
On failure, a negative number is returned.
Was that so difficult?