所以我是C新手,我試圖通過如下鏈接列表實現購物車。「類型名稱需要說明符或限定符」是什麼意思?
typedef struct {
char *name;
int count;
struct node *next;
} item;
struct cart {
item *curr, *head;
head = NULL;
};
當我去,雖然編譯,我得到以下錯誤:
[email protected]:~> clang shopper.c
shopper.c:14:3: error: type name requires a specifier or qualifier
head = NULL;
^
shopper.c:14:3: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
head = NULL;
^~~~
shopper.c:14:3: error: duplicate member 'head'
shopper.c:13:16: note: previous declaration is here
item *curr, *head;
^
shopper.c:14:7: error: expected ';' at end of declaration list
head = NULL;
^
;
我猜這個問題的根源是
type name requires a specifier or qualifier
但我不能圖這意味着什麼。