简体   繁体   English

c头文件的编程结构

[英]c programming structure to header file

how to get input for structure inside a header file. 如何获取头文件中结构的输入。 i am getting an error when trying to ask the user for input in the header file. 尝试要求用户在头文件中输入时出现错误。

#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);}

insideheader 内页眉

 void input(struct planecat aisle[6],struct planecat window[6]){
 {
   int i;
   printf("enter name");
   scanf("%i",&aisle[i].first_holdr);}

the program is giving me error by error C2036: 'planecat *' : unknown size 程序通过error C2036: 'planecat *' : unknown size给我错误error C2036: 'planecat *' : unknown size

 error C2037: left of 'seatmark' specifies undefined struct/union 'planecat'

Definition should go before usage. 定义应在使用前进行。 You have to place struct planecat{...} at the beginning of header file (preferred), or before #include "input.h" (bad style). 您必须将struct planecat{...}放在头文件的开头(首选),或者在#include "input.h" (错误的样式)之前。

put these 把这些

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 
};

in the input.h , and before the void input………… 在input.h中,以及在void输入之前…………

And I advise you to put your definition in your head file, and others in the cpp/c files 我建议您将定义放在头文件中,将其他定义放在cpp / c文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM