printf

S

Serve Laurijssen

Is it true that the return value of printf changed over different standards?

Somebody told me this but I find that hard to believe because the C
standards have alwas been very conservative about changing things that might
break existing code. But who knows, it might be true :)
 
B

Ben Pfaff

Serve Laurijssen said:
Is it true that the return value of printf changed over different standards?

Not really. Here's what the C89 final draft says:

The printf function returns the number of characters transmitted,
or a negative value if an output error occurred.

Here's what C99 says:

The printf function returns the number of characters
transmitted, or a negative value if an output or encoding
error occurred.

However, snprintf's return value has changed in many
implementations: pre-standardization, it returned -1 to indicate
that the output buffer was not big enough, but the standard
function returns the required output size.
 
L

lawrence.jones

Serve Laurijssen said:
Is it true that the return value of printf changed over different standards?

No. They may have been thinking of sprintf, which some pre-ANSI
libraries had returning a char * (the buffer pointer) rather than an int
(the number of characters output).

-Larry Jones

Oh yeah? You just wait! -- Calvin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top