C语言错误 [Error] expected declaration specifiers or '...' before 'student'
2018-02-01 20:40
791 查看
建立了一个学员管理系统,编译时发现set.h中发送了错误,查过,试了很多种方法,弄了一下午还是没弄出来
[Error] expected declaration specifiers or '...' before 'student'
set.c文件
#include<stdio.h>
typedef struct
{
char num[20]; //学号
char name[10]; //姓名
char sex[3]; //性别
int age; //年龄
char birth[15]; //出生日期,字符型
float score; //成绩(浮点型)
} STU;
#define student STU //宏定义student 代表结构体 STU
student stu[10]={0}; //定义结构体数组
int n=0; //定义全局变量 n
/*********************************
* 函数名:set
* 描述:输入学生信息
* 参数:结构体student指针 p
*返 回值:空
*全局变量:结构体数组 stu[10] ,整型 n
* 作者:TY
*建立时间:2018.2.1
********************************/
void set(student *p)
{
int i;
printf("请输入学生的个数:"); //n个学生
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("请输入第%d个学生的信息:\n",i+1);
printf("学号:");
scanf("%s",&(p+i)->num);
printf("姓名:");
scanf("%s",&(p+i)->name);
printf("性别:");
scanf("%s",&(p+i)->sex);
printf("年龄:");
scanf("%d",&(p+i)->age);
printf("出生日期:");
scanf("%s",&(p+i)->birth);
printf("成绩:");
scanf("%f",&(p+i)->score);
printf("\n");
}
}
set.h文件
extern student;
extern stu[10];
extern STU;
extern int n;
void set(student *p); //录入学生信息函数声明 (这里出错[Error] expected declaration specifiers or '...' before 'student')
建立了一个学员管理系统,编译时发现set.h中发送了错误,查过,试了很多种方法,弄了一下午还是没弄出来
[Error] expected declaration specifiers or '...' before 'student'
set.c文件
#include<stdio.h>
typedef struct
{
char num[20]; //学号
char name[10]; //姓名
char sex[3]; //性别
int age; //年龄
char birth[15]; //出生日期,字符型
float score; //成绩(浮点型)
} STU;
#define student STU //宏定义student 代表结构体 STU
student stu[10]={0}; //定义结构体数组
int n=0; //定义全局变量 n
/*********************************
* 函数名:set
* 描述:输入学生信息
* 参数:结构体student指针 p
*返 回值:空
*全局变量:结构体数组 stu[10] ,整型 n
* 作者:TY
*建立时间:2018.2.1
********************************/
void set(student *p)
{
int i;
printf("请输入学生的个数:"); //n个学生
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("请输入第%d个学生的信息:\n",i+1);
printf("学号:");
scanf("%s",&(p+i)->num);
printf("姓名:");
scanf("%s",&(p+i)->name);
printf("性别:");
scanf("%s",&(p+i)->sex);
printf("年龄:");
scanf("%d",&(p+i)->age);
printf("出生日期:");
scanf("%s",&(p+i)->birth);
printf("成绩:");
scanf("%f",&(p+i)->score);
printf("\n");
}
}
set.h文件
extern student;
extern stu[10];
extern STU;
extern int n;
void set(student *p); //录入学生信息函数声明 (这里出错[Error] expected declaration specifiers or '...' before 'student')
相关文章推荐
- 【错误】error: expected declaration specifiers or ‘...’ before string constant
- error: expected declaration specifiers or '...' before错误
- 安装PHP时 jpeglib.h:954: error:expected declaration specifiers or ‘...’ before ‘FILE’ 错误解决
- C语言错误:error: expected ':', ',', ';', '}' or '__attribute__' before '=' tok 4000 en
- /sysroot/usr/include/search.h:19: error: expected declaration specifiers or '...' before '__free_fn_
- XXX.h:143: error: expected declaration specifiers or ‘...’ before ‘YYY’
- 【错误笔记】error: expected declaration specifiers or '...' before XXX
- 3:16: 错误: expected declaration specifiers or ‘...’ before string constant
- /home/zhang/code/hello/hello.c:3: error: expected declaration specifiers or ‘...’ before string cons
- error: expected declaration specifiers or ‘...’ before ‘FILE’
- error: expected declaration specifiers or ‘...’ before string constant
- error expected declaration specifiers or ‘...’ before ‘SElemType’
- error: expected declaration specifiers or '...' before ***
- linux error: expected declaration specifiers or '...' XXX
- C语言错误:expected declaration or statement at end of input
- gcc:编译 expected declaration specifiers or ‘...’ before
- libpam:shadow.h:error: expected declaration specifiers before '__THROW'
- error: expected declaration specifiers or '...' before xxx(xxx是函数形参)
- error: expected declaration specifiers before ‘return’
- expected declaration specifiers or ‘...’ before