C语言void print(struct student stu)是什么意思有什么作用,再帮我看看哪里错误了
#include<stdio.h>#include<string.h>#defineLZXL"%d\n%s\n%f\n%f\n%f\n"structstudent{int...
#include<stdio.h>
#include<string.h>
#define LZXL "%d\n%s\n%f\n%f\n%f\n"
struct student
{
int num;
char name[20];
float score[3];
};
void main()
{
void print(struct student)
struct student stu;
stu.num=1233;
strcpy(stu.name,"Li Li");
stu.score[0]=98.8;
stu.score[1]=45;
stu.score[2]=45.6;
print(stu);
}
void print(struct student stu)
{
printf(LZXL,stu.num,stu.name,stu.score[0],stu.score[1],stu.score[2]);
printf("\n");
} 展开
#include<string.h>
#define LZXL "%d\n%s\n%f\n%f\n%f\n"
struct student
{
int num;
char name[20];
float score[3];
};
void main()
{
void print(struct student)
struct student stu;
stu.num=1233;
strcpy(stu.name,"Li Li");
stu.score[0]=98.8;
stu.score[1]=45;
stu.score[2]=45.6;
print(stu);
}
void print(struct student stu)
{
printf(LZXL,stu.num,stu.name,stu.score[0],stu.score[1],stu.score[2]);
printf("\n");
} 展开
1个回答
展开全部
print的作用就是输出参数stu的信息
代码没大问题 就是少一个分号
如下
#include<stdio.h>
#include<string.h>
#define LZXL "%d\n%s\n%f\n%f\n%f\n"
struct student
{
int num;
char name[20];
float score[3];
};
void main()
{
void print(struct student);//函数声明 少一个分号
struct student stu;
stu.num=1233;
strcpy(stu.name,"Li Li");
stu.score[0]=98.8;
stu.score[1]=45;
stu.score[2]=45.6;
print(stu);
}
void print(struct student stu)
{
printf(LZXL,stu.num,stu.name,stu.score[0],stu.score[1],stu.score[2]);
printf("\n");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询