|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<string.h>
#define N 3
struct student
{
int name[15];
int num[15];
int pleace[15];
int id[15];
int age;
int address[200];
}stu[N]
void input(struct student stu[]);
void print(struct student stu[]);
void search(struct student stu[],int name[]);
void main()
{
int name[15];
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[i].name);
printf("学号: ");
scanf("%d", &stu[i].num);
printf("籍贯: ");
scanf("%d", &stu[i].place);
printf("身份证号: ");
scanf("%d", &stu[i].id);
printf("年龄: ");
scanf("%d", &stu[i].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[i].name,&stu[i].num,& stu[i].place, &stu[i].id, &stu[i].age, &stu[i].address);
}
void search(struct student stu[], char name[]);
{
int flag=0;
for(int i=0; i<N; i++)
if(strcmp(stu[i].name, name)==0)
{
printf("%d%d%d%d%d%d\n", &stu[i].name,&stu[i].num,& stu[i].place, &stu[i].id, &stu[i].age, &stu[i].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 : '}' |
|