我用vs2010学习版写c的时候定义了两个结构体,但是编译器不能识别其中的一个,怎么回事?

我用vs2010学习版写c的时候定义了两个结构体,但是编译器不能识别其中的一个,怎么回事?
struct studentd
{
double line;
float id;
char name[20];
float grade;
};
struct studentd *dp1,*dhead;
然后dp1=(struct studentd *)malloc(sizeof(struct studentd))的时候,调试显示sizeof(struct studentd))语法错误??这问题遇到两次了,第一次莫名其妙被我搞过去了。。
代码从每句看没有语法错误,但要注意
1、malloc函数引自正闹#include,必须包括
2、dp1=(struct studentd *)malloc(sizeof(struct studentd));这句赋答滚值不能放在函数外面
需要放在比如main或者自定义函数内。清清余
在struct前加上typedef试试
← 上一篇: 下一篇: →