views:

337

answers:

4

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
+12  A: 

int. On success, the total number of characters written is returned. On failure, a negative number is returned.

See reference here

brickner
A: 

printf()'s reference from MSDN:

Returns the number of characters printed, or a negative value if an error occurs.

abatishchev
A: 

This function return result of interaction with "Real World". ;)

Anton