0
我一直在试图学习在C中的结构,并无法弄清楚如何使这个代码工作。我不断收到此错误:如何让这个结构在C中工作?
incomplete type 'struct card' struct card aCard = {"Three", "Hearts"};
^
test.c:2:8:
note: forward declaration of
'struct card'
struct card aCard = {"Three", "Hearts"};
代码:
#include<stdio.h>
struct card aCard = {"Three", "Hearts"};
int main(void){
printf("%s", aCard.suit);
}
在声明任何变量之前,您需要定义什么'struct card'该结构类型。就像'struct acard {const char * number; const char * suit; };' – kaylum
C没有类型推断。 – user3386109