#include <stdlib.h>
#include <stdio.h>
struct foo{
int id;
char *bar;
char *baz[6];
};
int main(int argc, char **argv){
struct foo f;
f.id=1;
char *qux[6];
f.bar=argv[0];
f.baz=qux; // Marked line
return 1;
}
这只是一些测试代码,所以忽略qux实际上没有任何有用的东西。C:不兼容的类型?
我在标记行上发现一个错误,incompatible types when assigning to type ‘char *[6]’ from type ‘char **’
但在代码中将这两个变量定义为char *[6]
。任何见解?
' char * baz [6];'声明一个由6个指针组成的数组。如果你想声明一个指向数组的指针,写'char(* baz)[6];' – pmg 2011-03-02 09:09:44