(1) 想让自己的程序看上去简洁,把较长的那些声明定义抽出来,放到单独的头文件里。(2)程序由多个文件组成,把各文件共用的声明定义抽出来放到单独的头文件里。 怎么定义头文件里面的内容!!
/*头文件内容,假设名字是test.h*/
#ifndef MYHEADFILE
#define MYHEADFILE
void InitInterpolation();
void Draw_Border();
void Draw_Background();
void Draw_Gray();
#endif
/*以下是test.c的内容*/
#include "test.h"
/*后面就是各个函数的实现*/
头文件一般用于多个源码的工程,当然,单源码可以写头文件,这个只是一种风格或习惯,一般是程序的声明部分写在.h中,如你的
char mainmenu(void);
char getBookType (void);
char bookItem (void);
int getBookNumber(void);
还有就是fiction,nonFiction的声明,可写成
extern int fiction;
extern int nonfiction;
本回答被网友采纳