-4
#include<stdio.h>
main()
{
  char s[]="man";
  int i=0;
  printf("%c%c\n",s[i],i[s]);
}

o/p: m m

*Both s[i] and i[s] prints 'm' and 'm'. *However s[i]=m, that is acceptable,but how i[s]=m ??
*Can any one explain me about this please.

1 Answers1

1

It's because s[i] is equivalent to *(s + i), and due to the commutative properties of addition, *(s + i) is equal to *(i + s) which leads to i[s] being valid.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621