头文件的c编程结构
如何获取头文件内部结构的输入。我在试图要求用户输入头文件时出错头文件的c编程结构,c,C,如何获取头文件内部结构的输入。我在试图要求用户输入头文件时出错 #include "input.h" struct planecat{ char seat_Id; //id num of seat int seatmark; //seat availability char first_holdr[20]; //first name of the seat holder char last_holdr[20]; //last name of the seat holder };
#include "input.h"
struct planecat{
char seat_Id; //id num of seat
int seatmark; //seat availability
char first_holdr[20]; //first name of the seat holder
char last_holdr[20]; //last name of the seat holder
};
int main(){ struct planecat aisle[6],window[6];
select_b(aisle,window);}
内部领导
void input(struct planecat aisle[6],struct planecat window[6]){
{
int i;
printf("enter name");
scanf("%i",&aisle[i].first_holdr);}
程序通过错误C2036:“planecat*”:未知大小给了我错误
error C2037: left of 'seatmark' specifies undefined struct/union 'planecat'
定义应该在使用之前。您必须将struct planecat{…}
放在头文件的开头(首选),或者放在#include“input.h”
之前(错误样式)。将这些
struct planecat{
char seat_Id; //id num of seat
int seatmark; //seat availability
char first_holdr[20]; //first name of the seat holder
char last_holdr[20]; //last name of the seat holder
};
在输入.h中,在无效输入之前
我建议你把你的定义放在你的头文件里,其他的放在cpp/c文件里这到底是怎么编译的?有2到几个结束括号。你是否已经复制/粘贴了?你的结构定义必须是前面的。在头中定义的输入函数,在CPP中声明的结构,在头使用它之后。还要考虑TyPulf。