Different way of accessing array elements in C

前端 未结 8 2343
有刺的猬
有刺的猬 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:38

    if str is an array of type char, then we can access any index say i as below-

    1. str[i]
    2. *(str + i)
    3. char *p = str, then access the index i as p[i] or *(p+i)

提交回复
热议问题