首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"hashLink“之前的预期表达式

"hashLink“之前的预期表达式
EN

Stack Overflow用户
提问于 2013-08-26 00:14:29
回答 1查看 131关注 0票数 1

我搞错了,我搞不懂。我试图定义一个结构的实例。我在代码中做了几次这样的操作,每次都会得到相同的错误。我不知道我做错了什么。

结构定义:

代码语言:javascript
复制
 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;

调用代码(一个例子):

代码语言:javascript
复制
hashLink *temp = malloc(sizeof hashLink);
hashLink *temp2 = malloc(sizeof hashLink);

我得到的精确错误是:

代码语言:javascript
复制
 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'|
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-26 00:24:05

sizeof hashLink -> sizeof(hashLink)

当与类型一起使用时,运算符sizeof需要括号。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18434988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档