不懂就问
#include<stdio.h>#include<string.h>
#define N 3
struct student
{
int name;
int num;
int pleace;
int id;
int age;
int address;
}stu
void input(struct student stu[]);
void print(struct student stu[]);
void search(struct student stu[],int name[]);
void main()
{
int name;
input(stu);
print(stu);
printf("\n请输入想要查找的学生姓名: ");
scanf("%d", name);
search(stu, name);
}
void input(struct student stu[]);
{
for(int i=0;i<N;i++);
{
printf("输入第%d个学生的信息\n",&i+1);
printf("姓名: ");
scanf("%d", &stu.name);
printf("学号: ");
scanf("%d", &stu.num);
printf("籍贯: ");
scanf("%d", &stu.place);
printf("身份证号: ");
scanf("%d", &stu.id);
printf("年龄: ");
scanf("%d", &stu.age);
printf("家庭住址: ");
}
}
void print(struct student stu[]);
{
printf("姓名学号 籍贯 身份证号 年龄地址 \n");
for(int i=0; i<N; i++)
printf("%d%d%d%d%d%d\n", &stu.name,&stu.num,& stu.place, &stu.id, &stu.age, &stu.address);
}
void search(struct student stu[], char name[]);
{
int flag=0;
for(int i=0; i<N; i++)
if(strcmp(stu.name, name)==0)
{
printf("%d%d%d%d%d%d\n", &stu.name,&stu.num,& stu.place, &stu.id, &stu.age, &stu.address);
flag = 1;
}
if(flag == 0)
printf("没有该学生的信息!\n");
}
报错如下:1、C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(15) : error C2054: expected '(' to follow 'stu'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(15) : error C2085: 'input' : not in formal parameter list
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(16) : error C2085: 'print' : not in formal parameter list
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(17) : error C2085: 'search' : not in formal parameter list
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(18) : error C2085: 'main' : not in formal parameter list
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(29) : error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(45) : error C2059: syntax error : '}'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(47) : error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(51) : error C2059: syntax error : '}'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(53) : error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\2\3.c(63) : error C2059: syntax error : '}'{:10_297:} struct student
{
int name;
int num;
int pleace;
int id;
int age;
int address;
}stu
没加分号?
页:
[1]