C language printf method, parameter calculation order

This article is reprinted, if you offend, please contact

printf("", a, b, c, d, e ); //Calculate from right to left

#include<sdtio.h>

void main()
{
    int a=100;
    printf(" %d %d %d %d \n", a++, a++, a++, a++);
}

What do you want to output, 100, 101, 102, 103? No, it is the reverse of 103, 102, 101, 100, printf calculates the output from the end to the front.

I saw a very interesting program today:

Determine the output of the following program:

 

#include <stdio.h>
#include <stdlib.h>
int main() 
{
     int i=43; 
      printf("%d\n",printf("%d",printf("%d",i)));
      system("pause");
      return 0;
 }

 

   The final output is 4321

  I have only encountered the case of the value represented by the output variable, and have not encountered the case of a direct value. After inspection and investigation, it is found that the program first executes the innermost printf, which is to output the value of i in integer form and output the content It is 43, and then execute the printf next to the outside, that is, the output of 43 is the number of bits 2. In the same way, the outermost printf is executed, and the number of output 2 is 1, so the final result of the program output is 4321.

Guess you like

Origin blog.csdn.net/qq_36909245/article/details/106108522
Recommended