我搞错了,我搞不懂。我试图定义一个结构的实例。我在代码中做了几次这样的操作,每次都会得到相同的错误。我不知道我做错了什么。
结构定义:
struct hashLink {
KeyType key; /*the key is what you use to look up a hashLink*/
ValueType value; /*the value stored with the hashLink, a pointer to int in the case of concordance*/
struct hashLink * next; /*notice how these are like linked list nodes*/
};
typedef struct hashLink hashLink;调用代码(一个例子):
hashLink *temp = malloc(sizeof hashLink);
hashLink *temp2 = malloc(sizeof hashLink);我得到的精确错误是:
C:\Users\Marshall\C\CS261\hashMap.c||In function '_freeMap':|
C:\Users\Marshall\C\CS261\hashMap.c|73|error: expected expression before 'hashLink'|
C:\Users\Marshall\C\CS261\hashMap.c|74|error: expected expression before 'hashLink'|发布于 2013-08-26 00:24:05
sizeof hashLink -> sizeof(hashLink)
当与类型一起使用时,运算符sizeof需要括号。
https://stackoverflow.com/questions/18434988
复制相似问题