CPP常用头文件及函数汇总

合集下载

c++常用头文件

c++常用头文件

c++常⽤头⽂件1.#include<iostream>iostream 的意思是输⼊输出流。

#include<iostream>是标准的C++头⽂件,任何符合标准的C++开发环境都有这个头⽂件。

2.#include<fsteram>fstream是 STL中对⽂件操作的合集,包含了常⽤的所有⽂件操作。

其中包含basic_ifstream,basic_ofstream,basic_fstream,basic_filebuf,ifstream,ofstream,fstream,filebuf,wifstream,wofstream, wfstream,wfilebuf 这些类。

其中ifstream⽤于输⼊⽂件流的类,ofstream⽤于输出⽂件流的类,fstream是⽂件流的类,filebuf是⽂件流缓冲区的类。

在C++中,所有的⽂件操作,都是以流(stream)的⽅式进⾏的,fstream也就是⽂件流file stream。

其中basic修饰的是模板类,不带w修饰的是⽤于窄字符(char)的类如ifstream,ofstream,fstream,filebuf,带w修饰的类是⽤于宽字符(w_char)的类如wifstream,wofstream,wfstream,wfilebuf。

最常⽤的两种操作为:1).插⼊器(<<) 向流输出数据。

⽐如说打开了⼀个⽂件流fout,那么调⽤fout<<"Write to file"<<endl;就表⽰把字符串"Write to file"写⼊⽂件并换⾏。

2).析取器(>>) 从流中输⼊数据。

⽐如说打开了⽂件流fin,那么定义整型变量x的情况下,fin>>x;就是从⽂件中读取⼀个整型数据,并存储到x中。

在C++11中,<chrono>是标准模板库中与时间有关的头⽂件。

C++中头文件(.h)和源文件(.cpp)都应该写些什么

C++中头文件(.h)和源文件(.cpp)都应该写些什么

C++中头⽂件(.h)和源⽂件(.cpp)都应该写些什么头⽂件(.h):写类的声明(包括类⾥⾯的成员和⽅法的声明)、函数原型、#define常数等,但⼀般来说不写出具体的实现。

在写头⽂件时需要注意,在开头和结尾处必须按照如下样式加上预编译语句(如下):#ifndef CIRCLE_H#define CIRCLE_H//你的代码写在这⾥#endif这样做是为了防⽌重复编译,不这样做就有可能出错。

⾄于CIRCLE_H这个名字实际上是⽆所谓的,你叫什么都⾏,只要符合规范都⾏。

原则上来说,⾮常建议把它写成这种形式,因为⽐较容易和头⽂件的名字对应。

源⽂件(.cpp):源⽂件主要写实现头⽂件中已经声明的那些函数的具体代码。

需要注意的是,开头必须#include⼀下实现的头⽂件,以及要⽤到的头⽂件。

那么当你需要⽤到⾃⼰写的头⽂件中的类时,只需要#include进来就⾏了。

下⾯举个最简单的例⼦来描述⼀下,咱就求个圆⾯积。

第1步,建⽴⼀个空⼯程(以在VS2003环境下为例)。

第2步,在头⽂件的⽂件夹⾥新建⼀个名为Circle.h的头⽂件,它的内容如下:#ifndef CIRCLE_H#define CIRCLE_Hclass Circle{private:double r;//半径public:Circle();//构造函数Circle(double R);//构造函数double Area();//求⾯积函数};#endif注意到开头结尾的预编译语句。

在头⽂件⾥,并不写出函数的具体实现。

第3步,要给出Circle类的具体实现,因此,在源⽂件夹⾥新建⼀个Circle.cpp的⽂件,它的内容如下:#include "Circle.h"Circle::Circle(){this->r=5.0;}Circle::Circle(double R){this->r=R;}double Circle:: Area(){return 3.14*r*r;}需要注意的是:开头处包含了Circle.h,事实上,只要此cpp⽂件⽤到的⽂件,都要包含进来!这个⽂件的名字其实不⼀定要叫Circle.cpp,但⾮常建议cpp⽂件与头⽂件相对应。

CPP语法总结

CPP语法总结

C++语法总结(一)1. I/O流的常用控制符dec 置基数为10hex 置基数为16oct 置基数为8setfill(c) 设填充字符为Csetprecision(n) 设显示小数精度为n位setw(n) 设域宽为N个字符setiosflags(ios::fixed) 固定的符点显示setiosflags(ios::scientific)指数表示setiosflags(ios::left) 左对齐setiosflags(ios::right) 右对齐setiosflags(ios::skipws) 忽略前导空白setiosflags(ios::uppercase) 16进制数大写输出setiosflags(ios::lowercase) 6进制数小写输出setiosflags(ios::showpoint) 显示小数点setiosflags(ios::showpos) 正数前面加上正号2.头文件:*iostream.h* *iomanip.h* *stdlib.h*cout/cin 流的控制符 exit(0)3.指针的几种类型:int (*p)();p为指向函数的指针变量,该函数带回一个整形值int *p();p为带回一个指针的函数,该指针指向整形数据int (**)[n]p为一个指向一个指针变量的指针变量,被指向的指针变量指向一个含n个整形数据的一维数组4.构造函数和析构函数特点及其区别:a.构造函数可以有任意个形参,还可以重载(多个参数个数不同的函数);但析构函数不能有形参,因为是系统自动调用的.b.构造函数不可以任意调用,只准系统调用;而析构函数不仅系统调用,也可以任意调用.5.构造函数和析构函数什么时候自动运行?(例61)构造函数:一般在定义类对象时自动运行.析构函数:如果一个函数中定义了一个对象,则在这个函数运行结束时就执行一次;当一个对象是使用NEW运算符被动态创建的,在使用DELETE运算符释放它时,DELETE将会自动调用析构函数.拷贝初始化构造函数:当用tpoint N(M);语句时调用一次;当对象作为实参向形参传递时,即对形参初始化时执行一次;当遇到M=return(N);语句,即对M进行初始化时调用一次;6. this 指针用法:例63中,当程序执行语句list elem(i);时,系统对this指针进行了如下的缺省赋值:this=&list;赋值成员函数举例(此例在例63基础上):void Assign(linear_list&);//说明语句;void linear_list::Assign(linear_list&p){if(&p==this)return;nmax=p.nmax;nelem=p.nelem;list=new int[nmax];for(int i=0;i<nmax;i++)list[i]=p.list[i];}7.const,volatile对象和const,volatile成员函数格式:const person per/volatile person per;int func(int) const;/char func(int) volatile;说明:1.普通对象既可以访问const对象,又可以访问volatile对象;2.const对象只能访问用const修饰的成员函数;volatile对象只能访问用其所长volatile修饰的成员函数;3.也可以同时说明为const volatile对象或const volatile成员函数;const volatile对象只能访问const volatile成员函数;const/volatile对象也能访问const volatile成员函数;8.不同继承方式的基类和派生类特性------------------------------------------------继承方式 | 基类特性 | 派生类特性------------------------------------------------| public | public公有继承 | protected | protected| private | 不可访问------------------------------------------------| public | private私有继承 | protected | private| private | 不可访问------------------------------------------------| public | protected保护继承 | protected | protected| private | 不可访问------------------------------------------------A:帮助理解:1)对于公有继承方式:a.基类成员对其对象的可见性:公有成员可见,其他不可见。

c语言中常用的函数和头文件

c语言中常用的函数和头文件

头文件ctype.h函数列表<>函数类别函数用途详细说明字符测试是否字母和数字isalnum是否字母isalpha是否控制字符iscntrl是否数字isdigit是否可显示字符(除空格外)isgraph是否可显示字符(包括空格)isprint是否既不是空格,又不是字母和数字的可显示字符ispunct是否空格isspace是否大写字母isupper是否16进制数字(0-9,A-F)字符isxdigit字符大小写转换函数转换为大写字母toupper转换为小写字母tolower地区化本类别的函数用于处理不同国家的语言差异。

头文件local.h函数列表函数类别函数用途详细说明地区控制地区设置setlocale数字格式约定查询国家的货币、日期、时间等的格式转换localeconv数学函数本分类给出了各种数学计算函数,必须提醒的是ANSI C标准中的数据格式并不符合IEEE754标准,一些C语言编译器却遵循IEEE754(例如frinklin C51)头文件math.h函数列表函数类别函数用途详细说明错误条件处理定义域错误(函数的输入参数值不在规定的范围内)值域错误(函数的返回值不在规定的范围内)三角函数反余弦acos反正弦asin反正切atan反正切2 atan2余弦cos正弦sin正切tan双曲函数双曲余弦cosh双曲正弦sinh双曲正切tanh指数和对数指数函数exp指数分解函数frexp乘积指数函数fdexp自然对数log以10为底的对数log10浮点数分解函数modf幂函数幂函数pow平方根函数sqrt整数截断,绝对值和求余数函数求下限接近整数ceil绝对值fabs求上限接近整数floor求余数fmod本分类函数用于实现在不同底函数之间直接跳转代码。

头文件setjmp.h io.h函数列表函数类别函数用途详细说明保存调用环境setjmp恢复调用环境longjmp信号处理该分类函数用于处理那些在程序执行过程中发生例外的情况。

c 标准库函数手册

c 标准库函数手册

c 标准库函数手册C 标准库函数手册。

C 标准库函数是 C 语言提供的一组函数库,它包含了一系列常用的函数,可以帮助程序员更高效地完成各种任务。

本手册将介绍 C 标准库函数的常用函数及其用法,帮助读者更加深入地理解和运用这些函数。

一、stdio.h。

stdio.h 是 C 语言中用来进行输入输出操作的头文件,它包含了一系列与标准输入输出相关的函数。

其中,最常用的函数包括 printf、scanf、fopen、fclose 等。

这些函数可以帮助程序员进行屏幕输出、键盘输入、文件读写等操作。

例如,printf 函数可以用来向屏幕输出格式化的字符串,而 scanf 函数则可以用来从键盘接收输入并存储到变量中。

二、stdlib.h。

stdlib.h 是 C 语言中的标准库头文件之一,它包含了一系列与内存分配、随机数生成、字符串转换等功能相关的函数。

其中,最常用的函数包括 malloc、free、rand、atoi 等。

这些函数可以帮助程序员进行动态内存分配、随机数生成、字符串转换等操作。

例如,malloc 函数可以用来动态分配指定大小的内存空间,而 rand 函数则可以用来生成一个指定范围内的随机数。

三、math.h。

math.h 是 C 语言中的标准数学库头文件,它包含了一系列与数学运算相关的函数。

其中,最常用的函数包括 sin、cos、sqrt、pow 等。

这些函数可以帮助程序员进行各种数学运算,如三角函数计算、平方根计算、幂运算等。

例如,sin 函数可以用来计算给定角度的正弦值,而 sqrt 函数则可以用来计算一个数的平方根。

四、string.h。

string.h 是 C 语言中的标准字符串库头文件,它包含了一系列与字符串操作相关的函数。

其中,最常用的函数包括 strlen、strcpy、strcat、strcmp 等。

这些函数可以帮助程序员进行字符串的长度计算、复制、连接、比较等操作。

例如,strlen 函数可以用来计算一个字符串的长度,而 strcpy 函数则可以用来将一个字符串复制到另一个字符串中。

常用C语言标准库函数

常用C语言标准库函数

常用C语言标准库函数C语言编译系统提供了众多的预定义库函数和宏。

用户在编写程序时,可以直接调用这些库函数和宏。

这里选择了初学者常用的一些库函数,简单介绍了各函数的用法和所在的头文件。

1.测试函数Isalnum原型:int isalnum(int c)功能:测试参数c是否为字母或数字:是则返回非零;否则返回零头文件:ctype.hIsapha原型:int isapha(int c)功能:测试参数c是否为字母:是则返回非零;否则返回零头文件:ctype.hIsascii原型:int isascii(int c)功能:测试参数c是否为ASCII码(0x00~0x7F):是则返回非零;否则返回零头文件:ctype.hIscntrl原型:int iscntrl(int c)功能:测试参数c是否为控制字符(0x00~0x1F、0x7F):是则返回非零;否则返回零头文件:ctype.hIsdigit原型:int isdigit(int c)功能:测试参数c是否为数字:是则返回非零;否则返回零。

头文件:ctype.hIsgraph原型:int isgraph(int c)功能:测试参数c是否为可打印字符(0x21~0x7E):是则返回非零;否则返回零头文件:ctype.hIslower原型:int islower(int c)功能:测试参数c是否为小写字母:是则返回非零;否则返回零头文件:ctype.hIsprint原型:int isprint(int c)功能:测试参数c是否为可打印字符(含空格符0x20~0x7E):是则返回非零;否则返回零头文件:ctype.hIspunct原型:int ispunct(int c)功能:测试参数c是否为标点符号:是则返回非零;否则返回零头文件:ctype.hIsupper原型:int isupper(inr c)功能:测试参数c是否为大写字母:是则返回非零;否则返回零Isxdigit原型:int isxdigit(int c)功能:测试参数c是否为十六进制数:是则返回非零;否则返回零2.数学函数abs原型:int abs(int i)功能:返回整数型参数i的绝对值头文件:stdlib.h,math.hacos原型:double acos(double x)功能:返回双精度参数x的反余弦三角函数值头文件:math.hasin原型:double asin(double x)功能:返回双精度参数x的反正弦三角函数值头文件:math.hatan原型:double atan(double x)功能:返回双精度参数的反正切三角函数值头文件:math.hatan2原型:double atan2(double y,double x)功能:返回双精度参数y和x由式y/x所计算的反正切三角函数值头文件:math.hcabs原型:double cabs(struct complex znum)功能:返回一个双精度数,为计算出复数znum的绝对值。

C语言头文件大全

C语言头文件大全

标准C语言头文件ISO C标准定义的头文件(24项)<assert.h> 验证程序断言<complex.h> 支持复数算术运算<ctype.h> 字符类型<errno.h> 出错码<fenv.h> 浮点环境<float.h> 浮点常量<inttypes.h> 整型格式转换<iso646.h> 替代关系操作符宏<limits.h> 实现常量<locale.h> 局部类别<math.h> 数学常量<setjmp.h> 非局部goto<signal.h> 信号<stdarg.h> 可变参数表<stdbool.h> 布尔类型和值<stddef.h> 标准定义<stdint.h> 整型<stdio.h> 标准I/O库<stdlib.h> 实用程序库函数<string.h> 字符串操作<tgmath.h> 通用类型数学宏<time.h> 时间和日期<wchar.h> 宽字符支持<wctype.h> 宽字符分类和映射支持POSIX标准定义的必须的头文件(26项)<dirent.h> 目录项<fcntl.h> 文件控制<fnmatch.h> 文件名匹配类型<glob.h> 路径名模式匹配类型<grp.h> 组文件<netdb.h> 网络数据库操作<pwd.h> 口令文件<regex.h> 正则表达式<tar.h> tar归档值<termios.h> 终端I/O <unistd.h> 符号常量<utime.h> 文件时间<wordexp.h> 字扩展类型<arpa/inet.h> Internet定义<net/if.h> 套接字本地接口<netinet/in.h> Internet地址族 <netinet/tcp.h> 传输控制协议<sys/mman.h> 内存管理声明<sys/select.h> select函数<sys/socket.h> 套接字接口<sys/stat.h> 文件状态<sys/times.h> 进程时间<sys/types.h> 基本系统数据类型<sys/un.h> UNIX域套接字定义<sys/utsname.h>系统名<sys/wait.h> 进程控制POSIX标准定义的XSI扩展头文件(26项)<cpio.h> cpio归档值<dlfcn.h> 动态链接<fmtmsg.h> 消息显示结构<ftw.h> 文件树漫游<iconv.h> 代码集转换实用程序<langinfo.h> 语言信息常量<libgen.h> 模式匹配函数定义<monetary.h> 货币类型<ndbm.h> 数据库操作<nl_types.h> 消息类别<poll.h> 轮询函数<search.h> 搜索表<strings.h> 字符串操作<syslog.h> 系统出错日志记录<ucontext.h> 用户上下文<ulimit.h> 用户限制<utmpx.h> 用户帐户数据库<sys/ipc.h> IPC<sys/msg.h> 消息队列<sys/resource.h> 资源操作<sys/sem.h> 信号量<sys/shm.h> 共享存储<sys/statvfs.h> 文件系统信息<sys/time.h> 时间类型<sys/timeb.h> 附加的时间<sys/uio.h> 矢量I/O操作POSIX标准定义的可选头文件(8项)<aio.h> 异步I/O <mqueue.h> 消息队列<pthread.h> 线程<sched.h> 执行调度<semaphore.h> 信号量<spawn.h> 实时spawn接口<stropts.h> XSI STREAMS接口<trace.h> 时间跟踪标准 C++ 语言头文件(54个其中16个用于构建STL,3个为附加非必须)<algorithm>STL通用算法<bitset> STL位集容器<cassert> 用于在程序运行时执行断言<cctype> 字符处理<cerrno> 错误码<cfloat> 用于测试浮点类型属性<ciso646> ISO646变体字符集<climits> 测试整数类型属性<clocale> 本地化函数<cmath> 数学函数<complex>复数类<csetjmp> 执行非内部的goto语句<csignal> 信号<cstdarg> 访问参数数量变化的函数<cstddef> 用于定义实用的类型和宏<cstdio> 输入/输出<cstdlib> 杂项函数及内存分配<cstring> 字符串<ctime> 时间<cwchar> 宽字符处理及输入/输出<cwctype> 宽字符分类<deque> STL双端队列容器<exception> 异常处理类<fstream> 文件流<functional> STL函数对象<iomanip> 参数化输入/输出<ios>基本输入/输出支持<iosfwd> 输入/输出前置声明<iostream> 数据流输入/输出<istream> 基本输入流<iterator> 遍历序列的类<limits> 各种数据类型最值常量<list>STL线性列表容器<locale> 国际化支持<map> STL映射容器<memory> 专用内存分配器<new> 基本内存分配和释放<numeric> 通用的数字操作<ostream> 基本输出流<queue> STL 队列容器<set> STL 集合容器<sstream> 基于字符串的流<stack> STL 堆栈容器<stdexcept> 标准异常类<streambuf> iostream 的缓冲区类<string> 字符串类<strstream> 非内存字符序列的流类<typeinfo> 运行时类型标识<utility> STL 通用模板类<valarray> 支持值数组的类和模版类<vector> STL 动态数组容器标准C++附加的头文件(3个)非必须<hash_map> <hash_set> <slist>The Standard C++ library consists of 51 required headers.This implementation also includes three additional headers,<hash_map>,<hash_set>,and <slist>,not required by the C++ Standard,for a total of 54 headers.Of these 54 headers,16 constitute the Standard Template Library,or STL.These are indicated below with the notation<algorithm> -- (STL) for defining numerous templates that implement useful algorithms<bitset> -- for defining a template class that administers sets of bits<complex> -- for defining a template class that supports complex arithmetic<deque> -- (STL) for defining a template class that implements a deque container<exception> -- for defining several functions that control exception handling<fstream> -- for defining several iostreams template classes that manipulate exteral files<functional>-- (STL) for defining several templates that help construct predicates for the templates defined in <algorithm> and <numeric><hash_map> -- (STL) for defining template classes that implement hashed associative containersthat map keys to values<hash_set> -- (STL) for defining template classes that implement hashed associative containers<iomanip> -- for declaring several iostreams manipulators that take an argument<ios> -- for defining the template class that serves as the base for many iostreams classes<iosfwd> -- for declaring several iostreams template classes before they are necessarilydefined<iostream> -- for declaring the iostreams objects that manipulate the standard streams<istream> -- for defining the template class that performs extractions<iterator> -- (STL) for defining several templates that help define and manipulate iterators<limits> -- for testing numeric type properties<list>-- (STL) for defining a template class that implements a doubly linked list container<locale> -- for defining several classes and templates that controllocale-specific behavior, as in the iostreams classes<map>-- (STL) for defining template classes that implement associative containers thatmap keys to values<memory>-- (STL) for defining several templates that allocate and free storage for variouscontainer classes<new> -- for declaring several functions that allocate and free storage<numeric>-- (STL) for defining several templates that implement useful numeric functions<ostream> -- for defining the template class that performs insertions<queue> -- (STL) for defining a template class that implements a queue container<set>-- (STL) for defining template classes that implement associative containers<slist>-- (STL) for defining a template class that implements a singly linked list container<sstream> -- for defining several iostreams template classes that manipulate string containers<stack> -- (STL) for defining a template class that implements a stack container<stdexcept> -- for defining several classes useful for reporting exceptions<streambuf> -- for defining template classes that buffer iostreams operations<string> -- for defining a template class that implements a string container<strstream> -- for defining several iostreams classes that manipulate in-memory character sequences<typeinfo> -- for defining class type_info, the result of the typeid operator<utility>-- (STL) for defining several templates of general utility<valarray> -- for defining several classes and template classes that support value-oriented arrays<vector>-- (STL) for defining a template class that implements a vector container新的C标准库<cassert> -- for enforcing assertions when functions execute<cctype> -- for classifying characters<cerrno> -- for testing error codes reported by library functions<cfloat> -- for testing floating-point type properties<ciso646> -- for programming in ISO 646 variant character sets<climits> -- for testing integer type properties<clocale> -- for adapting to different cultural conventions<cmath> -- for computing common mathematical functions<csetjmp> -- for executing nonlocal goto statements<csignal> -- for controlling various exceptional conditions<cstdarg> -- for accessing a varying number of arguments<cstddef> -- for defining several useful types and macros<cstdio> -- for performing input and output<cstdlib> -- for performing a variety of operations<cstring> -- for manipulating several kinds of strings<ctime> -- for converting between various time and date formats<cwchar> -- for manipulating wide streams and several kinds of strings<cwctype> -- for classifying wide characters旧的C标准库<assert.h> -- for enforcing assertions when functions execute<ctype.h> -- for classifying characters<errno.h> -- for testing error codes reported by library functions<float.h> -- for testing floating-point type properties<iso646.h> -- for programming in ISO 646 variant character sets<limits.h> -- for testing integer type properties<locale.h> -- for adapting to different cultural conventions<math.h> -- for computing common mathematical functions<setjmp.h> -- for executing nonlocal goto statements<signal.h> -- for controlling various exceptional conditions<stdarg.h> -- for accessing a varying number of arguments<stddef.h> -- for defining several useful types and macros<stdio.h> -- for performing input and output<stdlib.h> -- for performing a variety of operations<string.h> -- for manipulating several kinds of strings<time.h> -- for converting between various time and date formats<wchar.h> -- for manipulating wide streams and several kinds of strings<wctype.h> -- for classifying wide charactersFinally, in this implementation, the Standard C++ library also includes several headers for compatibility with traditional C++ libraries:<fstream.h> -- for defining several iostreams template classes that manipulate exteral files <iomanip.h> -- for declaring several iostreams manipulators that take an argument<iostream.h> -- for declaring the iostreams objects that manipulate the standard streams <new.h> -- for declaring several functions that allocate and free storage<stl.h> -- for declaring several template classes that aid migration from older versions of the Standard Template Library。

CC++中的头文件stdio.h和stdlib.h

CC++中的头文件stdio.h和stdlib.h

CC++中的头⽂件stdio.h和stdlib.h stdio 就是指 “standard input & output" 标准输⼊输出stdio.h所包含的函数:⽂件访问fopenfreopenfflushfclose⼆进制输⼊/输出freadfwrite⾮格式化输⼊/输出fgetc/getcfputc/putcungetcfgetsfputs格式化输⼊/输出scanf/fscanf/sscanfprintf/fprintf/sprintfperror⽂件定位ftellfseekfgetposfsetposrewind错误处理feofferror⽂件操作removerenametmpfile----------------------------------------------------------------------------stdlib 头⽂件即standard library标准库函数头⽂件stdlib 头⽂件⾥包含了C、C++语⾔的最常⽤的系统函数该⽂件包含了C语⾔标准库函数的定义stdlib.h所包含的函数:1函数名称:calloc函数原型: void calloc(unsigned n,unsigned size);函数功能: 分配n个数据项的内存连续空间,每个数据项的⼤⼩为 size函数返回: 分配内存单元的起始地址,如果不成功,返回02函数名称:free函数原型: void free(void* p);函数功能: 释放 p 所指的内存区函数返回:参数说明: p- 被释放的指针3函数名称:malloc函数原型: void * malloc(unsigned size);函数功能: 分配 size 字节的存储区函数返回: 所分配的内存区地址,如果内存不够,返回04函数名称: realloc函数原型: void * realloc(void * p,unsigned size);函数功能: 将 p 所指出的已分配内存区的⼤⼩改为 size,size 可以⽐原来分配的空间⼤或⼩函数返回: 返回指向该内存区的指针.NULL-分配失败5函数名称: rand函数原型: int rand(void);函数功能: 产⽣0到32767间的随机整数(0到0x7fff之间)函数返回: 随机整数6函数名称: abort函数原型: void abort(void)函数功能: 异常终⽌⼀个进程.7函数名称: exit函数原型: void exit(int state)函数功能: 程序中⽌执⾏,返回调⽤过程函数返回:参数说明: state:0- 正常中⽌,⾮ 0- ⾮正常中⽌8函数名称: getenv函数原型: char* getenv(const char *name)函数功能: 返回⼀个指向环境变量的指针函数返回:环境变量的定义参数说明: name- 环境字符串9函数名称: putenv函数原型: int putenv(const char *name)函数功能: 将字符串name增加到DOS环境变量中函数返回: 0:操作成功,-1:操作失败参数说明: name-环境字符串10函数名称: labs函数原型: long labs(long num)函数功能: 求长整型参数的绝对值函数返回:绝对值11函数名称: atof函数原型: double atof(char *str)函数功能: 将字符串转换成⼀个双精度数值函数返回: 转换后的数值参数说明: str- 待转换浮点型数的字符串12函数名称: atoi函数原型: int atoi(char *str)函数功能: 将字符串转换成⼀个整数值函数返回: 转换后的数值参数说明: str- 待转换为整型数的字符串13函数名称: atol函数原型: long atol(char *str)函数功能: 将字符串转换成⼀个长整数函数返回: 转换后的数值参数说明: str- 待转换为长整型的字符串14函数名称:ecvt函数原型: char *ecvt(double value,int ndigit,int *dec,int *sign)函数功能: 将浮点数转换为字符串函数返回: 转换后的字符串指针参数说明: value- 待转换底浮点数,ndigit- 转换后的字符串长度15函数名称:fcvt函数原型: char *fcvt(double value,int ndigit,int *dec,int *sign)函数功能: 将浮点数变成⼀个字符串函数返回: 转换后字符串指针参数说明: value- 待转换底浮点数,ndigit- 转换后底字符串长度。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include <complex>//复数类#include <csignal> //信号机制支持#include <csetjmp> //异常处理支持#include <cstdarg> //不定参数列表支持#include <cstddef> //常用常量#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 <locale> //本地化特定信息#include <map>//STL 映射容器#include <memory> //STL通过分配器进行的内存分配#include <new> //动态内存分配#include <numeric> //STL常用的数字操作#include <iomanip> //参数化输入/输出#include <ios>//基本输入/输出支持#include <iosfwd>//输入/输出系统使用的前置声明#include <iostream> //数据流输入/输出#include <istream>//基本输入流#include <iterator> //STL迭代器#include <ostream>//基本输出流#include <queue>//STL 队列容器#include <set>//STL 集合容器#include <sstream>//基于字符串的流#include <stack>//STL 堆栈容器#include <stdexcept>//标准异常类#include <streambuf>//底层输入/输出支持#include <string>//字符串类#include <typeinfo> //运行期间类型信息#include <utility>//STL 通用模板类#include <valarray> //对包含值的数组的操作#include <vector>//STL 动态数组容器————————————————————————————————C99增加的部分#include <complex.h>//复数处理#include <fenv.h>//浮点环境#include <inttypes.h>//整数格式转换#include <stdbool.h>//布尔环境#include <stdint.h>//整型环境#include <tgmath.h>//通用类型数学宏头文件ctype.h字符处理函数: 本类别函数用于对单个字符进行处理,包括字符的类别测试和字符的大小写转换----------------------------------------字符测试是否字母和数字isalnum是否字母isalpha是否控制字符iscntrl是否数字isdigit是否可显示字符(除空格外) isgraph是否可显示字符(包括空格) isprint是否既不是空格,又不是字母和数字的可显示字符ispunct是否空格isspace是否大写字母isupper是否16进制数字(0-9,A-F)字符isxdigit字符大小写转换函数转换为大写字母toupper转换为小写字母tolower头文件local.h地区化: 本类别的函数用于处理不同国家的语言差异。

----------------------------------------地区控制地区设置setlocale数字格式约定查询国家的货币、日期、时间等的格式转换localeconv头文件math.h数学函数: 本分类给出了各种数学计算函数,必须提醒的是ANSI C标准中的数据格式并不符合IEEE754标准,一些C语言编译器却遵循IEEE754(例如frinklin C51)----------------------------------------反余弦acos反正弦asin反正切atan反正切2 atan2余弦cos正弦sin正切tan双曲余弦cosh双曲正弦sinh双曲正切tanh指数函数exp指数分解函数frexp乘积指数函数fdexp自然对数log以10为底的对数log10浮点数分解函数modf幂函数pow平方根函数sqrt求下限接近整数ceil绝对值fabs求上限接近整数floor求余数fmod头文件setjmp.h io.h本分类函数用于实现在不同底函数之间直接跳转代码。

----------------------------------------保存调用环境setjmp恢复调用环境longjmp头文件signal.h信号处理: 该分类函数用于处理那些在程序执行过程中发生例外的情况。

----------------------------------------指定信号处理函数signal发送信号raise头文件stdarg.h可变参数处理: 本类函数用于实现诸如printf,scanf等参数数量可变底函数。

----------------------------------------可变参数访问宏可变参数开始宏va_start可变参数结束宏va_end可变参数访问宏访问下一个可变参数宏va_arg头文件stdio.h输入输出函数:该分类用于处理包括文件、控制台等各种输入输出设备,各种函数以“流”的方式实现----------------------------------------删除文件remove修改文件名称rename生成临时文件名称tmpfile得到临时文件路径tmpnam文件访问关闭文件fclose刷新缓冲区fflush打开文件fopen将已存在的流指针和新文件连接freopen 设置磁盘缓冲区setbuf设置磁盘缓冲区setvbuf格式化输入与输出函数格式输出fprintf格式输入fscanf格式输出(控制台) printf格式输入(控制台) scanf格式输出到缓冲区sprintf从缓冲区中按格式输入sscanf格式化输出vfprintf格式化输出vprintf格式化输出vsprintf字符输入输出函数输入一个字符fgetc字符串输入fgets字符输出fputc字符串输出fputs字符输入(控制台) getc字符输入(控制台) getchar字符串输入(控制台) gets字符输出(控制台) putc字符输出(控制台) putchar字符串输出(控制台) puts字符输出到流的头部ungetc直接输入输出直接流读操作fread直接流写操作fwrite文件定位函数得到文件位置fgetpos文件位置移动fseek文件位置设置fsetpos得到文件位置ftell文件位置复零位remind错误处理函数错误清除clearerr文件结尾判断feof文件错误检测ferror得到错误提示字符串perror头文件stdlib.h实用工具函数: 本分类给出了一些函数无法按以上分类,但又是编程所必须要的。

----------------------------------------字符串转换函数字符串转换为整数atoi字符串转换为长整数atol字符串转换为浮点数strtod字符串转换为长整数strtol字符串转换为无符号长整型strtoul伪随机序列产生函数产生随机数rand设置随机函数的起动数值srand存储管理函数分配存储器calloc释放存储器free存储器分配malloc重新分配存储器realloc环境通信中止程序abort退出程序执行,并清除环境变量atexit退出程序执行exit读取环境参数getenv程序挂起,临时执行一个其他程序system搜索和排序工具二分查找(数据必须已排序) bsearch快速排序qsort整数运算函数求绝对值abs得到除法运算底商和余数div求长整形底绝对值labs求长整形除法的商和余数ldiv多字节字符函数得到多字节字符的字节数mblen得到多字节字符的字节数mbtowc多字节字符转换wctomb多字节字符的字符串操作将多字节串转换为整数数组mbstowcs 将多字节串转换为字符数组mcstowbs头文件string.h字符串处理: 本分类的函数用于对字符串进行合并、比较等操作----------------------------------------字符串拷贝块拷贝(目的和源存储区不可重叠) memcpy块拷贝(目的和源存储区可重叠) memmove串拷贝strcpy按长度的串拷贝strncpy字符串连接函数串连接strcat按长度连接字符串strncat串比较函数块比较memcmp字符串比较strcmp字符串比较(用于非英文字符) strcoll按长度对字符串比较strncmp字符串转换strxfrm字符与字符串查找字符查找memchr字符查找strchr字符串查找strcspn字符串查找strpbrk字符串查找strspn字符串查找strstr字符串分解strtok杂类函数字符串设置memset错误字符串映射strerror求字符串长度strlen头文件time.h日期和时间函数: 本类别给出时间和日期处理函数----------------------------------------时间操作函数得到处理器时间clock得到时间差difftime设置时间mktime得到时间time时间转换函数得到以ASCII码表示的时间asctime得到字符串表示的时间ctime得到指定格式的时间strftime序号库类别头文件----------------------------------------1 错误处理errno.h2 字符处理ctyphe.3 地区化local.h4 数学函数math.h5 信号处理signal.h6 输入输出stdio.h7 实用工具程序stdlib.h8 字符串处理string.h。

相关文档
最新文档