要求会员'不是结构或工会

Eri*_*lho 2 c

我正在尝试使用一个结构数组,每次我尝试为任何结构分配一个值时,它会给我这个错误:

request for member 's' in something not a structure or union
Run Code Online (Sandbox Code Playgroud)

我的结构:

struct {
    char s;
    int lineNum;
} item;
Run Code Online (Sandbox Code Playgroud)

我这样声明:

struct item * stack[100];
Run Code Online (Sandbox Code Playgroud)

然后:

/* both lines gives me the error */
    stack[0].s = 'a';
    stack[0].lineNum = 1;
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么吗?

pmg*_*pmg 8

你没有struct item.

stack 是一个指向尚未定义的结构的100指针的数组.

尝试

struct item {
    char s;
    int lineNum;
};
Run Code Online (Sandbox Code Playgroud)