-1

I am confused about how the printf statement is working in this program? I want to know the way of executing.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a=5;
    printf("%d %d %d %d\n",a++,++a,++a,1);
    printf("%d",a);
    //printf("Hello world!\n");
    return 0;
}
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
selva
  • 97
  • 1
  • 5

1 Answers1

1

This will invoke undefined behavior. Statement

 printf("%d %d %d %d\n",a++,++a,++a,1);  

trying to modify a thrice between two sequence point.

haccks
  • 104,019
  • 25
  • 176
  • 264