#include <stdio.h> #define NUM 8 typedef struct game { char *b[NUM]; char *c[NUM]; }GAME; int main() { GAME game1; char *s[] = {"abc", "bcd", "cde", "def", "efg", "fgh", "sdf", "sdf"}; // 1:没出错误 game1.b[] = {"abc", "bcd", "cde", "def", "efg", "fgh", "sdf", "sdf"}; // 2:编译错误 game1.c[1] = "abc"; // 3:没出错误 printf("%s\n", game1.b[1]); return 0; } |
原帖由 cugb_cat 于 2008-9-22 22:58 发表
2不是初始化
结构体中分量的初始化应该是:
GAME game1 = {{"abc", "bcd", "cde", "def", "efg", "fgh", "sdf", "sdf"}, {NULL, NULL}};
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |