0

so i compline this code in C

#include <stdio.h>
int main()
{
   int a = 1;
   printf("%d",a++);
   printf("%d",a);
   printf("%d",++a);

   int b =1;
   printf("\n%d%d%d",b++,b,++b);

}

out in gcc 123 233

out in clang 123 123

  • Welcome to the wonderful world of *undefined behavior*. – Some programmer dude Oct 13 '22 at 14:46
  • It is one of the most frequent duplicates here. OP did not even try to do any research – 0___________ Oct 13 '22 at 14:48
  • 1
    On a different note, please make it a habit to print *trailing* newlines rather than leading. If `stdout` (which is where `printf` writes) is connected to a terminal, then it's *line buffered*. That means output is actually written on newline. When you print a leading newline then you writ the *previous* line, not the current one. – Some programmer dude Oct 13 '22 at 14:49

0 Answers0