示例
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h> //C99特性
#include <string.h>
#include <math.h>
#include <ctype.h>
/*
标准规定具有内部链接的函数可以成为内联函数,还规定了内联函数
的定义与调用该函数的代码必须在同一个文件中。因此,最简单的方法
是使用函数说明符inline和存储类别说明符static。通常,内联函数应定义
在首次使用它的文件中,所以内联函数也相当于函数原型。
注意:内联函数应该比较短小。
由于并未给内联函数预留单独的代码块,所以无法获得内联函数的地址(实际上可以
获得地址,不过这样做之后,编译器会生成一个非内联函数)。另外,内联函数无法
在调式器中显示。
通常把内联函数放入头文件中
*/
//内联函数定义/原型
#ifndef EATLINE_H_
#define EATLINE_H_
inline static void eatline()
{
while (getchar() != '\n')
continue;
}
#endif
int main(int argc, char* argv[])
{
//编译器会用内联函数的函数体替换函数调用
eatline();
system("pause");
return 0;
}