<分区>
Possible Duplicate:
How to create an array of string in C?
在我的 Last question 中我写了下面几行代码
#include <stdio.h>
int main(void){
char str1[] = {'f','i'};
char str2[] = {'s','e'};
char str3[] = {'t','h'};
char *arry_of_string[] = {str1,str2,str3};
printf("%s\n",arry_of_string[1]);
}
感谢人们指出我应该在字符串末尾的 '\0' 处。我学会了这样做的正确方法。我很好奇错误代码的结果:
安全
我记得在 C 引用书中,指针寻找 '\0' 我认为没有 \0
终止符,结果应该是:
seth
因为 str3 是数组中的下一个元素。谁能从数组的内部结构上解释一下为什么?