Char pointer weird expression in c -
this question has answer here:
- with arrays, why case a[5] == 5[a]? 15 answers
i know why code running.
code:
#include <stdio.h> int main(int argc, char* argv[]) { char* c = "1234567"; printf("%c\n", 5[c]); return 0; }
result:
6
if confused a[b]
syntax, refresh c knowledge.
a[b]
defined *(a + b)
, since a+b
same b+a
, a[b]
, b[a]
.
Comments
Post a Comment