keil不能够使用结构体?
typedeffloatDataType;typedefstruct{DataType*data;intmax;inttop;}Stack;voidSetStack(St...
typedef float DataType;
typedef struct
{
DataType *data;
int max;
int top;
}Stack;
void SetStack(Stack *S,int n)
{
S->data=(DataType*)malloc(n*sizeof(DataType));
if(S->data==NULL)
{
printf("overflow");
exit(1);
}
S->max=n;
S->top=-1;
}
然后再编译的时候就报错了
51.C(39): error C141: syntax error near ';'
51.C(42): error C141: syntax error near '}'
51.C(43): error C141: syntax error near '*', expected ')'
51.C(45): error C141: syntax error near 'data', expected '<id>'
51.C(46): error C141: syntax error near 'data', expected '<id>'
51.C(46): error C141: syntax error near ')' 展开
typedef struct
{
DataType *data;
int max;
int top;
}Stack;
void SetStack(Stack *S,int n)
{
S->data=(DataType*)malloc(n*sizeof(DataType));
if(S->data==NULL)
{
printf("overflow");
exit(1);
}
S->max=n;
S->top=-1;
}
然后再编译的时候就报错了
51.C(39): error C141: syntax error near ';'
51.C(42): error C141: syntax error near '}'
51.C(43): error C141: syntax error near '*', expected ')'
51.C(45): error C141: syntax error near 'data', expected '<id>'
51.C(46): error C141: syntax error near 'data', expected '<id>'
51.C(46): error C141: syntax error near ')' 展开
2个回答
展开全部
类型声明错误。按楼上的格式改。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询