问题描述:

This question already has an answer here:

  • What does printf return?

    4 answers

网友答案:

printf return the number of characters printed

In your case that statement can be broken like this - the output is expected:

    printf("%d\n", // 1
           printf("%d", // 2
                  printf("%d",i)    // 43
                 )
          );  // 4321

For more information, consult the standard fprintf (printf is special case of fprintf with the stream being stdout)

7.21.6.1 The fprintf function

 #include <stdio.h>
       int fprintf(FILE * restrict stream,
           const char * restrict format, ...);

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

相关阅读:
Top