Different way of accessing array elements in C

前端 未结 8 2339
有刺的猬
有刺的猬 2020-11-30 04:49

I am a teaching assistant for a C programming course, and I came across the following line of C code:

char str[] = \"My cat\'s name is Wiggles.\";
printf(\"%         


        
8条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 05:44

    str[5] directly translates to *(str + 5), and 5[str] directly translates to *(5 + str). Same thing =)

提交回复
热议问题