您的位置:首页 > 编程语言 > C语言/C++

每天学一点c++:c++常用的头文件介绍

2014-03-30 23:37 162 查看
  c++常用的头文件:

#include <algorithm> //STL 通用算法

#include <bitset> //STL 位集容器

#include <cassert>  //包含的宏和信息用于添加有助于程序调试的诊断。

#include <cctype> //字符处理

#include <cerrno> //定义错误码

#include <clocale> //定义本地化函数

#include <cmath> //定义数学函数

#include <complex> //复数类
#include <cstdio> //定义输入/输出函数
#include <cstdlib> //定义杂项函数及内存分配函数

#include <cstring> //字符串处理

#include <ctime> //定义关于时间的函数

#include <cwchar> //宽字符处理及输入/输出

#include <cwctype> //宽字符分类

#include <deque> //STL 双端队列容器

#include <exception> //异常处理类

#include <fstream> //文件输入/输出

#include <functional> //STL 定义运算函数(代替运算符)

#include <limits> /定义各种数据类型最值常量

#include <list> //STL 线性列表容器

#include <map> //STL 映射容器

#include <iomanip> //参数化输入/输出

#include <ios> //基本输入/输出支持
#include <iosfwd> //输入/输出系统使用的前置声明

#include <iostream> //数据流输入/输出

#include <istream> //基本输入流

#include <ostream> //基本输出流

#include <queue> //STL 队列容器

#include <set> //STL 集合容器

#include <sstream> //基于字符串的流

#include <stack> //STL 堆栈容器

#include <stdexcept> //标准异常类

#include <streambuf> //底层输入/输出支持

#include <string> //字符串类

#include <utility> //STL 通用模板类

#include <vector> //STL 动态数组容器

常用函数:

数学函数,所在函数库为math.h、stdlib.h、string.h、float.h

int abs(int i) ;//返回整型参数i的绝对值
double cabs(struct complex znum);// 返回复数znum的绝对值

double fabs(double x);// 返回双精度参数x的绝对值

long labs(long n) ;//返回长整型参数n的绝对值

double exp(double x);// 返回指数函数ex的值
double frexp(double value,int *eptr);// 返回value=x*2n中x的值,n存贮在eptr中
double ldexp(double value,int exp); //返回value*2exp的值

double log(double x) ;//返回logex的值

double log10(double x);// 返回log10x的值

double pow(double x,double y);// 返回x^y的值

double pow10(int p);// 返回10^p的值

double sqrt(double x);// 返回+√x的值
double acos(double x) ;//返回x的反余弦cos-1(x)值,x为弧度

double asin(double x);// 返回x的反正弦sin-1(x)值,x为弧度

double atan(double x) ;//返回x的反正切tan-1(x)值,x为弧度
double atan2(double y,double x) ;//返回y/x的反正切tan-1(x)值,y的x为弧度
double cos(double x);// 返回x的余弦cos(x)值,x为弧度

double sin(double x);// 返回x的正弦sin(x)值,x为弧度

double tan(double x);// 返回x的正切tan(x)值,x为弧度
double cosh(double x);// 返回x的双曲余弦cosh(x)值,x为弧度

double sinh(double x);// 返回x的双曲正弦sinh(x)值,x为弧度

double tanh(double x);// 返回x的双曲正切tanh(x)值,x为弧度

double hypot(double x,double y);// 返回直角三角形斜边的长度(z), x和y为直角边的长度,z2=x2+y2
double ceil(double x);// 返回不小于x的最小整数

double floor(double x);// 返回不大于x的最大整数

void srand(unsigned seed) ;//初始化随机数发生器

int rand() ;//产生一个随机数并返回这个数
double poly(double x,int n,double c[]);//从参数产生一个多项式
double modf(double value,double *iptr);//将双精度数value分解成尾数和阶

double fmod(double x,double y) ;//返回x/y的余数
double frexp(double value,int *eptr);// 将双精度数value分成尾数和阶

double atof(char *nptr) ;//将字符串nptr转换成浮点数并返回这个浮点数

double atoi(char *nptr) ;//将字符串nptr转换成整数并返回这个整数

double atol(char *nptr) ;//将字符串nptr转换成长整数并返回这个整数

char *ecvt(double value,int ndigit,int *decpt,int *sign);// 将浮点数value转换成字符串并返回该字符串
char *fcvt(double value,int ndigit,int *decpt,int *sign);// 将浮点数value转换成字符串并返回该字符串

进程函数,所在函数库为stdlib.h、process.h
void abort();// 此函数通过调用具有出口代码的_exit写一个终止信息于stderr,并异常终止程序。无返回值

int exec…装入和运行其它程序
int execl( char *pathname,char *arg0,char *arg1,…,char *argn,NULL);

int execle( char *pathname,char *arg0,char *arg1,…, char *argn,NULL,char *envp[])
int execlp( char *pathname,char *arg0,char *arg1,…,NULL)
int execlpe(char *pathname,char *arg0,char *arg1,…,NULL,char *envp[]) int execv( char *pathname,char *argv[])
int execve( char *pathname,char *argv[],char *envp[]) int execvp( char *pathname,char *argv[])
int execvpe(char *pathname,char *argv[],char *envp[])

exec函数族装入并运行程序pathname,并将参数
arg0(arg1,arg2,argv[],envp[])传递给子程序,出错返回-1

在exec函数族中,后缀l、v、p、e添加到exec后, 所指定的函数将具有某种操作能力
有后缀 p时,函数可以利用DOS的PATH变量查找子程序文件。

l时,函数中被传递的参数个数固定。

v时,函数中被传递的参数个数不固定。
e时,函数传递指定参数envp,允许改变子进程的环境,

无后缀e时,子进程使用当前程序的环境。
void _exit(int status);//终止当前程序,但不清理现场
void exit(int status) ;//终止当前程序,关闭所有文件,写缓冲区的输出(等待输出),并调用任何寄存器的"出口函数",无返回值

int kbhit() 本函数返回最近所敲的按键
int fgetchar() ;//从控制台(键盘)读一个字符,显示在屏幕上

int getch() ;//从控制台(键盘)读一个字符,不显示在屏幕上

int putch() ;//向控制台(键盘)写一个字符
int getchar() ;//从控制台(键盘)读一个字符,显示在屏幕上

int putchar() ;//向控制台(键盘)写一个字符
int getche() ;//从控制台(键盘)读一个字符,显示在屏幕上

int ungetch(int c) ;//把字符c退回给控制台(键盘)
char *cgets(char *string);// 从控制台(键盘)读入字符串存于string中

int scanf(char *format[,argument…]);//从控制台读入一个字符串,分别对各个参数进行赋值

int sscanf(char *string,char *format[,argument,…]);//通过字符串string,别对各个 参数进行赋值,参数从Vlist param中取得.

int puts(char *string) ;//发关一个字符串string给控制台(显示器),
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: