
C语言中各种Include的文件及作用?
#include <assert.h> //设定插入点
#include <ctype.h> //字符处理
#include <errno.h> //定义错误码
#include <float.h> //浮点数处理
#include <fstream.h> //文件输入/输出
#include <iomanip.h> //参数化输入/输出
#include <iostream.h> //数据流输入/输出
#include <limits.h> //定义各种数据类型最值常量
#include <locale.h> //定义本地化函数
#include <math.h> //定义数学函数
#include <stdio.h> //定义输入/输出函数
#include <stdlib.h> //定义杂项函数及内存分配函数
#include <string.h> //字符串处理
#include <strstrea.h> //基于数组的输入/输出
#include <time.h> //定义关于时间的函数
#include <wchar.h> //宽字符处理及输入/输出
#include <wctype.h> //宽字符分类
比如输入输出功能,要#include <stdio.h>
我们常用的printf函数就是在这个头文件中声明的。
实际上,在我们编写的程序里并未定义printf函数,那我们为什么可以用它呢?
原因就是他已经在stdio.h中声明了。
程序编译的时候,会经历一个预处理的过程,#include标记的头文件中的函数声明会被加入到目标文件中,然后经历过编译、链接,生成正确的目标程序。
比如用到测试字符串长度函数strlen(字符数组)就需要添加String.h这个头文件
格式为Include“String.h”
添加过后,程序在编译时会自动到String.h文件中搜索Strlen()函数