-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,004
  • 3
  • 24
  • 29

2 Answers2

7

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

nneonneo
  • 154,210
  • 32
  • 267
  • 343
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
  • 10,935
  • 10
  • 37
  • 61