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