Associativity of assignment operator in C -
this question has answer here:
i have code:
#include<stdio.h> main() { static int a[10]; int i=5; a[i]=i++;// **statement 1** printf("%d %d",a[6],a[5]); }
i following output:
0 5
since assignment operator rtl, shouldn't i++;
in statement 1 incremented , a[i] becomes a[6] before assignment?
doesn't statement 1 evaluate a[6]=5;
?
why a[5] becoming 5?
this becuase =
not sequence point c language. such, a[i] = i++
invokes undefined behaviour.
Comments
Post a Comment