Alex Rivera | Logout

Why does printf return a value?

Asked 2012-11-23T20:49:59.127
14

I know that printf returns a negative error or number of characters printed on success. Only reason to check this return value is if the execution of program somehow depends on the printf status. But I could not think of a scenario where this return value is useful. I, for one, have never checked the return value of printf function.

What are the scenarios where return status from printf is useful?

Edit
Report

1 Answer

0

in some cases, printf is only able to put a part of your string into stdout, and this is not an error.

if you have to be sure that your string is sended complete, you could use the return value to see this.

its mos useful when working with fprintf and sockets, etc. but still could be useful.

answered 2012-11-23T20:58:00.717

Your Answer