#define _CRT_SECURE_NO_DEPRECATE
#include <string.h>
#include <stdio.h>
struct Student
{
char no[9];
char name[21];
float score;
};
Student createStu()
{
Student stu;
printf("请输入学号:");
scanf("%s", stu.no);
printf("请输入姓名:");
scanf("%s", stu.name);
printf("请输入成绩:");
scanf("%f", &stu.score);
return stu;
}
int initStu(Student stu)
{
int i, j, k;
if (strlen(stu.no) <= 8)
i = 0;
else
i = 1;
if (strlen(stu.name) < 3 || strlen(stu.name) > 20)
j = 0;
else
j = 1;
if (stu.score > 100)
k = 0;
else
k = 1;
if (i == 0 || j == 0 || k == 0)
printf("0\n");
else
printf("1\n");
return 0;
}
void printStu(struct Student stu)
{
printf("学号:%d\n姓名:%s\n成绩:%f", stu.no, stu.name, stu.score);
}
int main()
{
Student tmpStu = createStu();
initStu(tmpStu);
printStu(tmpStu);
}
不知道你要做什么,只是猜着你的思路改了一下。