-6

The following code seems to execute fine but how is it valid and whats happening here?

    int i;
    printf("%d",i["11"]);
manojadams
  • 2,172
  • 3
  • 25
  • 29

2 Answers2

7

i["11"] == *("11" + i) == "11"[i]

nneonneo
  • 162,933
  • 34
  • 285
  • 360
1

when you do i["11"] what you do is say to the compiler to take the value of i and add to it the value of "11" and take the value on the address that is the sum of them

No Idea For Name
  • 11,127
  • 10
  • 38
  • 63