C/C++头文件一览
C
#include //设定插入点
#include //字符处理
#include //定义错误码
#include //浮点数处理
#include //对应各种运算符的宏
#include //定义各种数据类型最值的常量
#include //定义本地化C函数
#include //定义数学函数
#include //异常处理支持
#include //信号机制支持
#include //不定参数列表支持
#include //常用常量
#include //定义输入/输出函数
#include //定义杂项函数及内存分配函数
#include //字符串处理
#include //定义关于时间的函数
#include //宽字符处理及输入/输出
#include //宽字符分类
传统C++
#include //改用
#include //改用
#include //改用
#include //该类不再支持,改用中的stringstream
————————————————————————————————
标准C++
#include //STL 通用算法
#include //STL 位集容器
#include //字符处理
#include //定义错误码
#include //浮点数处理
#include //对应各种运算符的宏
#include //定义各种数据类型最值的常量
#include //定义本地化函数
#include //定义数学函数
#include //复数类
#include //信号机制支持
#include //异常处理支持
#include //不定参数列表支持
#include //常用常量
#include //定义输入/输出函数
#include //定义杂项函数及内存分配函数
#include //字符串处理
#include //定义关于时间的函数
#include //宽字符处理及输入/输出
#include //宽字符分类
#include //STL 双端队列容器
#include //异常处理类
#include //文件输入/输出
#include //STL 定义运算函数(代替运算符)
#include //定义各种数据类型最值常量
#include //STL 线性列表容器
#include //本地化特定信息
#include
C ++常用库函数
如图1所示,常用数学函数
头文件#include
函数原型 |
功能 |
返回值 |
int abs(int x) |
求整数X的绝对值 |
绝对值 |
双acos(双x) |
计算阿科斯(X)的值 |
计算结果 |
双asin(双x) |
计算阿尔辛(X)的值 |
计算结果 |
双atan(双x) |
计算反正切(X)的值 |
计算结果 |
双cos(双x) |
计算COS(X)的值 |
计算结果 |
双cosh(双x) |
计算X的双曲余弦COSH(X)的值 |
计算结果 |
double exp(双x) |
求的值 |
计算结果 |
双晶圆厂(双x) |
求实数X的绝对值 |
绝对值 |
双fmod(双x) |
求的x / y的余数 |
余数的双精度数 |
长实验室(长x) |
求长整型数的绝对值 |
绝对值 |
双日志(双x) |
计算(X)中的值 |
计算结果 |
双log10(双x) |
计算的值 |
计算结果 |
double modf(double x,double * y) |
取X的整数部分送到Ÿ所指向的单元格中 |
X的小树部分 |
双动力(双x,双y) |
求的值 |
计算结果 |
双罪(双x) |
计算的sin(x)的值 |
计算结果 |
双sqrt(双x) |
求的值 |
计算结果 |
双棕褐色(双x) |
计算黄褐色(X)的值 |
计算结果 |
fcvt |
将浮点型数转化为字符串 |
|
2,常用字符串处理函数
头文件#include
函数原型 |
功能 |
返回值 |
void * memcpy(void * p1,const void * p2 size_t n) |
存储器拷贝,将P2所指向的共ñ个字节拷贝到P1所指向的存储区中 |
目的存储区的起始地址 (实现任意数据类型之间的拷贝) |
void * memset(void * p int v,size_t n) |
将v的值作为p所指向的区域的 值中,n是p所指向区域的大小 |
该区域的起始地址 |
char * strcpy(char * p1,const char * p2) |
将P2所指向的字符串拷贝到 P1所指向的存储区中 |
目的存储区的起始地址 |
char * strcat(char * p1,const char * p2) |
将P2所指向的字符串连接到 P1所指向的字符串后面 |
目的存储区的起始地址 |
int strcmp(const char * p1,const char * p2) |
比较P1,P2所指向的两个 字符串的大小 |
两个字符串相同,返回0;若P1所指向的字符串小于P2所指的字符串,返回负值;否则,返回正值 |
int strlen(const char * p) |
求p所指向的字符串的长度 |
字符串所包含的字符个数 (不包括字符串结束标志'\ n') |
char * strncpy(char * p1,const char * p2,size_t n) |
将P2所指向的字符串(至多Ñ个字符)拷贝到P1所指向的存储区中 |
目的存储区的起始地址 (与的strcpy()类似) |
char * strncat(char * p1,const char * p2,size_t n) |
将P2所指向的字符串(至多Ñ个字符)连接到P1所指向的字符串的后面 |
目的存储区的起始地址 (与的strcpy()类似) |
char * strncmp(const char * p1,const char * p2,size_t n) |
比较P1,P2所指向的两个字符串的大小,至多比较Ñ个字符 |
两个字符串相同,返回0;若P1所指向的字符串小于P2所指的字符串,返回负值;否则,返回正值 (与的strcpy()类似) |
char * strstr(const char * p1,const char * p2) |
判断P2所指向的字符串是否是P1所指向的字符串的子串 |
若是子串,返回开始位置的地址;否则返回0。 |
|
|
|
3,其他常用函数
头文件#include
函数原型 |
功能 |
返回值 |
说明 |
void abort(void) |
终止程序执行 |
|
不能结束工作 |
void exit(int) |
终止程序执行 |
|
做结束工作 |
double atof(const char * s) |
将小号所指向的字符串转换成实数 |
实数值 |
|
int atoi(const char * s) |
将小号所指向的字符串转换成整数 |
整数值 |
|
long atol(const char * s) |
将小号所指的字符串转换成长整数 |
长整数值 |
|
int rand(void) |
产生一个随机整数 |
随机整数 |
|
void srand(unsigned int) |
初始化随机数产生器 |
|
|
int system(const char * s) |
将小号所指向的字符串作为一个可执行文件,并加以执行 |
|
|
最大值(a,b) |
求两个数中的大数 |
大数 |
参数为任意类型 |
分(A,B) |
求两个数中的小数 |
小数 |
参数为任意类型 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4,实现键盘和文件输入/输出的成员函数
头文件#include
函数原型 |
功能 |
返回值 |
cin >> v |
输入值送给变量 |
|
cout << exp |
输出表达式EXP的值 |
|
istream&istream :: get(char&c) |
输入字符送给变量Ç |
|
istream&istream :: get(char *,int,char ='\ n') |
输入一行字符串 |
|
istream&istream :: getline(char *,int,char ='\ n') |
输入一行字符串 |
|
void ifstream :: open(const char *,int = ios :: in, int = filebuf :: openprot) |
打开输入文件 |
|
void ofstream :: open(const char *,int = ios :: out, int = filebuf :: openprot) |
打开输出文件 |
|
void fsream :: open(const char *,int, int = filebuf :: openprot) |
打开输入/输出文件 |
|
ifstream :: ifstream(const char *,int = ios :: in, int = filebuf :: openprot) |
构造函数打开输入文件 |
|
ofstream :: ofstream(const char *,int = ios :: out, int = filebuf :: openprot) |
构造函数打开输出函数 |
|
fstream :: fstream(const char *,int, int = filebuf :: openprot) |
构造函数打开输入/输出文件 |
|
void istream :: close() |
关闭输入文件 |
|
void ofsream :: close() |
关闭输出文件 |
|
void fsream :: close() |
关闭输入/输出文件 |
|
istream&istream :: read(char *,int) |
从文件中读取数据 |
|
ostream&istream :: write(const char *,int) |
将数据写入文件中 |
|
int ios :: eof() |
判断是否到达打开文件的尾部 |
1为到达2为没有 |
istream&istream :: seekg(streampos) |
移动输入文件的指针 |
|
istream&istream :: seekg(streamoff,ios :: seek_dir) |
移动输入文件的指针 |
|
streampos istream :: tellg() |
取输入文件的指针 |
|
ostream&ostream :: seekp(streampos) |
移动输出文件的指针 |
|
ostream&ostream :: seekp(streamoff,ios :: seek_dir) |
移动输出文件的指针 |
|
streampos ostream :: tellp() |
取输出文件的指针 |
|
C ++的头文件!
#include //字符处理
#include //定义错误码
#include //浮点数处理
#include //文件输入/输出
#include //参数化输入/输出
#include //数据流输入/输出
#include //定义各种数据类型最值常量
#include //定义本地化函数
#include //定义数学函数
#include //定义输入/输出函数
#include //定义杂项函数及内存分配函数
#include //字符串处理
#include //基于数组的输入/输出
#include //定义关于时间的函数
#include //宽字符处理及输入/输出
#include //宽
字符分类 标准C ++(同上的不再注释)
#include // STL通用算法
#include // STL位集容器
#include
#include
#include
#include
#include //复数类
#include
#include
#include
#include
# include // STL双端队列容器
#include //异常处理类
#include
#include // STL定义运算函数(代替运算符)
#include
#include < list> // STL线性列表容器
#include