C语言的程序出现了错误 就高手指点 谢谢
#include;#include;structStudent{intsid;intage;}structStudent*CreateStudent(void);void...
#include;
#include;
struct Student
{
int sid;
int age;
}
struct Student * CreateStudent(void);
void ShowStudent(struct Student *);
int main(void)
{
struct Student *ps;
ps=CreateStudent();
ShowStudent(ps);
return 0;
}
void ShowStudent(struct Student *pst)
{
printf("%d %d\n",pst->sid ,pst->age);
}
struct Student * CreateStudent(void)
{
struct Student *p=(struct Student *)malloc(sizeof(struct Student));
p->sid=99;
p->age=88;
return p;
}
这段代码调试出现了以下错误 求高手解
--------------------Configuration: memorry_2 - Win32 Debug--------------------
Compiling...
memory_2.cpp
d:\program files\microsoft visual studio\c source\memory_2.cpp(1) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
D:\Program Files\Microsoft Visual Studio\C source\memory_2.cpp(2) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
D:\Program Files\Microsoft Visual Studio\C source\memory_2.cpp(9) : error C2236: unexpected 'struct' 'Student'
执行 cl.exe 时出错.
memory_2.obj - 1 error(s), 0 warning(s)
头文件 为
#include <stdio.h>;
#include <malloc.h>; 展开
#include;
struct Student
{
int sid;
int age;
}
struct Student * CreateStudent(void);
void ShowStudent(struct Student *);
int main(void)
{
struct Student *ps;
ps=CreateStudent();
ShowStudent(ps);
return 0;
}
void ShowStudent(struct Student *pst)
{
printf("%d %d\n",pst->sid ,pst->age);
}
struct Student * CreateStudent(void)
{
struct Student *p=(struct Student *)malloc(sizeof(struct Student));
p->sid=99;
p->age=88;
return p;
}
这段代码调试出现了以下错误 求高手解
--------------------Configuration: memorry_2 - Win32 Debug--------------------
Compiling...
memory_2.cpp
d:\program files\microsoft visual studio\c source\memory_2.cpp(1) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
D:\Program Files\Microsoft Visual Studio\C source\memory_2.cpp(2) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
D:\Program Files\Microsoft Visual Studio\C source\memory_2.cpp(9) : error C2236: unexpected 'struct' 'Student'
执行 cl.exe 时出错.
memory_2.obj - 1 error(s), 0 warning(s)
头文件 为
#include <stdio.h>;
#include <malloc.h>; 展开
展开全部
#include <stdio.h> //这行有问题
#include <malloc.h>
struct Student
{
int sid;
int age;
}; //这行有问题
struct Student * CreateStudent(void);
void ShowStudent(struct Student *);
int main(void)
{
struct Student *ps;
ps=CreateStudent();
ShowStudent(ps);
return 0;
}
void ShowStudent(struct Student *pst)
{
printf("%d %d\n",pst->sid ,pst->age);
}
struct Student * CreateStudent(void)
{
struct Student *p=(struct Student *)malloc(sizeof(struct Student));
p->sid=99;
p->age=88;
return p;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询