0

Possible Duplicate:
In C arrays why is this true? a[5] == 5[a]

Is this instruction correct in c :

5["abcdef"]

If yes, what does it mean ?

I had this question in a c test.

Community
  • 1
  • 1
Hicham
  • 983
  • 6
  • 17

2 Answers2

2

Yes, it is correct, and means the same as "abcdef"[5], which evaluates to 'f'.

It is because a[b] == *(a+b) == *(b+a) == b[a] by definition.

jpalecek
  • 47,058
  • 7
  • 102
  • 144
0

Yes.

The [] operator is commutative; that's the same as "abcdef"[5], which returns 'f'.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964