Today in my interview, the interviewer asked: printf is a function and every function returns something; int, void, float, etc. Now what does printf return as it's a function?
+6
A:
Not every function returns something, which is indicated by using void
:
void function_returns_nothing(void);
printf
is a function (declared in <stdio.h>
) and it returns an int
, which is the number of characters outputted. If an error occurs, the number is negative.
GMan
2010-05-16 20:24:17
+12
A:
int
. On success, the total number of characters written is returned.
On failure, a negative number is returned.
brickner
2010-05-16 20:24:29
A:
printf()
's reference from MSDN:
Returns the number of characters printed, or a negative value if an error occurs.
abatishchev
2010-05-16 20:28:16