# include <stdio.h>
# include <stdlib.h>
# include <string.h>
int main(void)
{
int i = 0;
char * p = NULL;
//通过字符串初始化字符数组, 并且增追加 \0
char buf4[] = "abcd";//buf[4]error,因为字符数组自动追加 \0 ,buf4本身字符占内存就是4个字节再加 \0 所以不对。
for (i = 0; i < strlen(buf4); i++)
{
printf("%c", buf4[i]);
}
printf("\n");
p = buf4;
for (i = 0; i < strlen(buf4); i++)
{
printf("%c", *(p+i));
}
printf("\n");
system("pause");
return 0;
}
首先抛出一个问题 :[ ] 的本质是什么?* 的本质是什么?先看看下面代码:# include <stdio.h># include <stdlib.h># include <string.h>int main(void){ int i = 0; char * p = NULL; //通过字符串初始化字符数组, 并且增追加 \0...