c语言函数库
c语言标准库函数

c语言标准库函数
C语言标准库函数是C语言编程中最基本、最重要的一类函数库,它由ANSI C语言指定,它们提供了程序设计师在编写C语言程序时所需要的基本功能,也是标准C语言程序的基础。
具体来说,C语言标准库函数包括输入/输出(I/O)函数、字符串函数、存储分配函数、数学函数、时间日期函数、多线程函数和其他函数。
输入/输出(I/O)函数可以用于显示文本、从文件读取和写入数据、处理文件名等;字符串函数用于处理字符串,如拼接字符串、比较字符串、查找字符串等;存储分配函数用于申请和释放内存;数学函数用于计算复杂的数学运算;时间日期函数用于处理时间和日期;多线程函数用于多线程编程;其他函数包括文件系统函数、环境变量函数和其他常用函数。
C语言标准库函数的优点在于它们可以让程序设计师快速搭建出符合标准的基本程序框架,大大提高编程的效率。
另外,C语言标准库函数的函数参数和返回值类型都是固定的,能够统一编程规范,避免不同程序员编写的代码有不同的风格。
此外,C语言标准库函数还有一个优点就是,它们不仅可以用于编写C语言程序,也可以用于编写C++程序。
在C++程序中,可以使用C语言标准库函数,以此更加容易地实现基本的功能,也不用考虑与C++语言本身的特性冲突的问题。
总而言之,C语言标准库函数是C语言编程的基础,它们的优点不言而喻,应该准确掌握C语言标准库函数的用法,以此提高编程效率。
C语言库函数大全

C语言库函数大全absread()读磁盘绝对扇区函数原形:int absread(int drive,int num,int sectnum,void *buf)功能:从drive指定的驱动器磁盘上,sectnum指定的逻辑扇区号开始读取(通过DOS中断0x25读取)num个(最多64K个)扇区的内容,储存于buf所指的缓冲区中。
参数:drive=0对应A盘,drive=1对应B盘。
返回值:0:成功;-1:失败。
头文件:dos.habswrite()写磁盘绝对扇区函数原形:int abswrite(int drive,int nsects,int lsect,void *buffer)drive=0(A驱动器)、1(B驱动器)、nsects=要写的扇区数(最多64K个);lsect=起始逻辑扇区号;buffer=要写入数据的内存起始地址。
功能:将指定内容写入(调用DOS中断0x26)磁盘上的指定扇区,即使写入的地方是磁盘的逻辑结构、文件、FAT表和目录结构所在的扇区,也照常进行。
返回值:0:成功;-1:失败。
头文件:dos.hatof()将字符串转换成浮点数的函数原形:double atof(const char *s)功能:把s所指向的字符串转换成double类型。
s格式为:符号数字.数字 E符号数字返回值:字符串的转换值。
头文件:math.h、stdlib.hatoi()将字符串转换成整型数的函数原形:int atoi(const char *s)功能:把s所指向的字符串转换成int类型。
s格式为:符号数字返回值:字符串的转换值。
若出错则返回0。
头文件:stdlib.hatol()将字符串转换成长整型数的函数原形:long atol(const char *s)功能:把s所指向的字符串转换成long int类型。
s格式为:符号数字返回值:字符串的转换值。
若出错则返回0。
头文件:stdlib.hbcd()把一个数转换成对应的BCD码的函数原形:bcd bcd(int x)bcd bcd(double x)bcd bcd(double x,int decimals)注意:BCD码的精度可达17位。
什么是C语言中的“库函数”?

什么是C语言中的“库函数”?库函数是在C语言中提供给开发者使用的已经编写好的函数集合。
它们是预先编写好的代码片段,供开发者在程序中调用和使用。
库函数可以用来执行一些常见的任务或者提供一些常用的功能,例如输入输出、字符串处理、数学计算等等。
C语言中的库函数通常分为两种类型:标准库函数和自定义库函数。
1. 标准库函数:标准库函数是C语言提供的基本函数库。
C语言标准库(C standard library)是C语言最基本的库函数集合,包含了针对C语言的标准化接口、常用宏定义和函数实现。
开发者可以通过引入标准库函数,快速地使用它们来编写程序。
标准库函数通常是平台无关的,可以在不同的操作系统上使用。
一些常见的标准库函数包括:- printf()和scanf():用于输出和输入信息。
- strlen()和strcpy():用于字符串处理。
- fopen()和fclose():用于文件操作。
- sqrt()和pow():用于数学计算。
2. 自定义库函数:自定义库函数是开发者自己编写的函数集合。
它们通常用于处理特定的任务或者提供特定的功能,以便在不同的程序中重复使用。
开发者可以根据自己的需求,编写自定义库函数,并将其组织成库文件(.lib或.a)。
然后,在其他程序中引入该库文件,即可使用自定义库函数。
自定义库函数可以提高开发效率,避免重复编写相同的代码。
它们可以将复杂的任务封装成简单的函数接口,提供给其他开发者使用。
自定义库函数的具体实现可以根据开发者的需求进行优化,以提高程序的性能和可靠性。
总结:库函数是C语言中的已编写好的函数集合,用于提供常见的功能和执行常见的任务。
它们分为标准库函数和自定义库函数。
开发者可以方便地使用标准库函数,并通过编写自定义库函数重复使用代码,提高开发效率和程序性能。
*注意:本文只是简单介绍了C语言中的库函数,具体的库函数和用法可以通过查阅相关文档进一步了解和掌握。
*。
c语言的函数库

c语言的函数库C语言作为一种常用的编程语言,在软件开发领域有着广泛的应用。
在C语言中,函数库是非常重要的一部分,通过函数库中提供的函数,我们可以更方便地编写程序,提高开发效率。
那么,C语言的函数库主要有哪些内容呢?C语言的函数库主要包括两部分:标准函数库和扩展函数库。
其中,标准函数库是所有C语言实现都必须提供的,包括stdio.h、stdlib.h、string.h、math.h、time.h等头文件。
这些头文件中提供了许多常用的函数,例如实现输入输出、字符串处理、数学运算、时间操作等。
这些函数库被广泛使用,而且在各个平台上都是一样的。
因此,开发者们可以在不同的平台上使用相同的代码。
另一部分是扩展函数库,也称为操作系统函数库。
扩展函数库提供了许多与操作系统相关的函数,例如文件操作、内存管理、进程控制等。
这些函数库的具体内容因操作系统不同而有所不同,例如在Windows 系统中,可以使用winsock.h库进行网络编程,在Linux系统中则可以使用unistd.h库访问Linux系统的API函数。
值得一提的是,C语言的函数库是由一些预编译的函数集合组成的,这些函数都是在头文件中声明的,并且实际的实现是提供给编译器的,编译器会将函数库中的函数编译成目标代码,然后链接到程序中。
因此,我们在编写程序时可以使用这些函数库中的函数,而无需手动实现。
在实际编写程序时,我们通过#include语句引入需要的头文件,就可以使用该文件中提供的函数。
例如,当我们需要进行文件操作时,就可以包含stdio.h头文件。
这个头文件中包含许多与文件操作相关的函数,例如fopen()、fclose()、fread()、fwirte()等。
这些函数都是在函数库中提供的,我们可以直接在程序中使用。
除此之外,我们还可以自己编写的函数添加到函数库中,以便在需要的时候调用。
为此,我们需要将函数编写在一个代码文件中,并通过编译器进行编译和链接,从而生成一个静态库或动态库。
c语言中库函数

c语言中库函数C语言是一种广泛使用的编程语言,它具有高效、简洁、灵活等特点,因此在各种应用领域都得到了广泛的应用。
在C语言中,库函数是非常重要的一部分,它们提供了各种各样的功能,可以帮助程序员更加方便地完成各种任务。
C语言中的库函数可以分为标准库函数和扩展库函数两种。
标准库函数是由C语言标准规定的,它们包含在C语言的标准库中,可以在任何C语言编译器中使用。
扩展库函数则是由各个编译器厂商或第三方开发者提供的,它们通常提供了一些标准库函数没有的功能,或者对标准库函数进行了优化。
C语言中的库函数可以分为以下几类:1. 字符串处理函数字符串处理函数是C语言中最常用的库函数之一,它们可以帮助程序员更加方便地处理字符串。
常用的字符串处理函数包括strlen、strcpy、strcat、strcmp等。
例如,strlen函数可以用来计算一个字符串的长度,strcpy函数可以将一个字符串复制到另一个字符串中,strcat函数可以将一个字符串连接到另一个字符串的末尾,strcmp函数可以比较两个字符串是否相等。
2. 数学函数数学函数是C语言中另一个非常重要的库函数类别,它们可以帮助程序员进行各种数学计算。
常用的数学函数包括sin、cos、tan、sqrt、pow等。
例如,sin函数可以计算一个角度的正弦值,cos函数可以计算一个角度的余弦值,tan函数可以计算一个角度的正切值,sqrt函数可以计算一个数的平方根,pow函数可以计算一个数的幂次方。
3. 文件操作函数文件操作函数是C语言中用来处理文件的库函数,它们可以帮助程序员读取、写入、创建、删除文件等。
常用的文件操作函数包括fopen、fclose、fread、fwrite、fseek等。
例如,fopen函数可以打开一个文件,fclose函数可以关闭一个文件,fread函数可以从文件中读取数据,fwrite函数可以向文件中写入数据,fseek函数可以移动文件指针的位置。
c语言标准库函数大全

c语言标准库函数大全C语言标准库函数大全。
C语言标准库函数是C语言程序设计中不可或缺的一部分,它包含了丰富的函数,可以帮助程序员完成各种任务,从输入输出到内存管理、字符串处理等。
本文将为大家详细介绍C语言标准库中常用的函数,希望能够帮助大家更好地理解和运用这些函数。
1. 输入输出函数。
输入输出函数是C语言程序设计中最基本的部分,它们可以帮助我们与用户进行交互,从而实现程序的输入和输出。
其中,printf和scanf是最常用的两个函数,它们分别用于输出和输入数据。
除此之外,还有一些其他的输入输出函数,如puts、gets、putc、getc等,它们分别用于输出字符串、输入字符串等操作。
2. 字符串处理函数。
在C语言标准库中,有许多用于处理字符串的函数,如strlen、strcpy、strcat、strcmp等。
这些函数可以帮助我们对字符串进行各种操作,比如计算字符串的长度、复制字符串、拼接字符串、比较字符串等。
字符串处理函数在实际的程序设计中非常常用,它们可以帮助我们高效地处理字符串数据。
3. 数学函数。
C语言标准库中还包含了丰富的数学函数,如sin、cos、tan、sqrt、pow等。
这些函数可以帮助我们进行各种数学运算,比如三角函数运算、开方运算、幂运算等。
数学函数在科学计算和工程计算中非常重要,它们可以帮助我们实现各种复杂的数学运算。
4. 内存管理函数。
内存管理函数是C语言程序设计中不可或缺的一部分,它们可以帮助我们对内存进行分配和释放。
其中,malloc和free是最常用的两个函数,它们分别用于分配和释放内存。
除此之外,还有一些其他的内存管理函数,如calloc、realloc等,它们分别用于分配多块内存、重新分配内存等操作。
5. 时间日期函数。
C语言标准库中还包含了一些用于处理时间日期的函数,如time、localtime、strftime等。
这些函数可以帮助我们获取当前的系统时间、将时间转换为字符串等操作。
c语言的库函数

c语言的库函数C语言是一门广泛应用于编程的语言,其库函数也是编程过程中必不可少的一部分。
本文将介绍C语言常用的库函数及其作用。
1. <stdio.h>这是C语言中最常用的库函数之一,用于输入输出操作。
其中包括了printf()、scanf()等函数。
printf()函数用于输出内容到控制台或文件中,其格式为printf("输出格式", 输出变量)。
scanf()函数用于从控制台或文件中获取输入,其格式为scanf("输入格式", 输入变量)。
2. <stdlib.h>这是C语言中的标准库函数之一,用于动态存储分配、数学计算、排序和字符串处理等操作。
其中包括了malloc()、free()、rand()等函数。
malloc()函数用于动态分配内存,其格式为malloc(分配大小)。
free()函数用于释放动态分配的内存,其格式为free(需要释放的内存指针)。
rand()函数用于生成随机数,其格式为rand()。
3. <string.h>这是C语言中的字符串处理函数库,其中包括了strcpy()、strcat()、strlen()等函数。
strcpy()函数用于将一个字符串复制到另一个字符串中,其格式为strcpy(目标字符串, 源字符串)。
strcat()函数用于将一个字符串连接到另一个字符串的末尾,其格式为strcat(目标字符串, 源字符串)。
strlen()函数用于计算一个字符串的长度,其格式为strlen(字符串)。
4. <math.h>这是C语言中的数学函数库,其中包括了sin()、cos()、tan()等函数。
sin()函数用于计算正弦值,其格式为sin(弧度值)。
cos()函数用于计算余弦值,其格式为cos(弧度值)。
tan()函数用于计算正切值,其格式为tan(弧度值)。
5. <ctype.h>这是C语言中的字符处理函数库,其中包括了isalpha()、isdigit()、toupper()等函数。
c语言标准函数库

c语言标准函数库C语言标准函数库。
C语言标准函数库(C standard library)是C语言的标准库,提供了一系列的函数、宏和变量,用于支持C语言的基本操作和功能。
C语言标准函数库包含在C语言标准中,并由各个C语言编译器实现和提供。
在本文中,我们将对C语言标准函数库进行详细介绍,包括其功能、常用函数以及使用方法。
C语言标准函数库的功能非常丰富,包括数学运算、字符串操作、输入输出、内存管理等多个方面。
其中,数学函数库包括了常见的数学运算函数,如求幂、开方、三角函数等;字符串函数库包括了字符串的处理函数,如字符串拷贝、比较、查找等;输入输出函数库包括了文件操作函数、标准输入输出函数等;内存管理函数库包括了动态内存分配函数、内存拷贝函数等。
在C语言标准函数库中,有一些函数是非常常用的,例如printf()、scanf()、malloc()、free()等。
其中,printf()函数用于将格式化的数据输出到标准输出设备,而scanf()函数用于从标准输入设备中读取格式化的数据。
malloc()函数用于动态分配内存空间,而free()函数用于释放之前动态分配的内存空间。
除了以上提到的函数外,C语言标准函数库还包括了大量其他的函数,如数学函数库中的sin()、cos()、tan()等三角函数,字符串函数库中的strcpy()、strcmp()、strlen()等字符串处理函数,输入输出函数库中的fopen()、fclose()、fread()、fwrite()等文件操作函数,以及内存管理函数库中的memcpy()、memset()等内存操作函数。
在使用C语言标准函数库时,我们需要包含相应的头文件,并链接相应的库文件。
例如,如果我们需要使用数学函数库中的sin()函数,就需要在程序中包含<math.h>头文件,并在编译链接时加上"-lm"选项。
同样,如果我们需要使用文件操作函数库中的fopen()函数,就需要包含<stdio.h>头文件,并在编译链接时不需要额外的选项。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
c语言标准函数库目录[隐藏]<assert.h><ctype.h><errno.h><float.h><limits.h><locale.h><math.h><setjmp.h><assert.h><ctype.h><errno.h><float.h><limits.h><locale.h><math.h><setjmp.h>∙<signal.h>∙<stdarg.h>∙<stddef.h>∙<stdio.h>∙<stdlib.h>∙<string.h>∙<time.h>[编辑本段]<assert.h>void assert(int expression);Macro used for internal error detection. (Ignored if NDEBUG is defined where <assert.h> is included.) If expression equals zero, message printed on stderr and abort called to terminate execution. Source filename and line number in message are from preprocessor macros __FILE__ and __LINE__.[编辑本段]<ctype.h>int isalnum(int c);isalpha(c) or isdigit(c)int isalpha(int c);isupper(c) or islower(c)int iscntrl(int c);is control character. In ASCII, control characters are 0x00 (NUL) to 0x1F (US), and 0 x7F (DEL)int isdigit(int c);is decimal digitint isgraph(int c);is printing character other than spaceint islower(int c);is lower-case letterint isprint(int c);is printing character (including space). In ASCII, printing characters are 0x20 (' ') to 0 x7E ('~')int ispunct(int c);is printing character other than space, letter, digitint isspace(int c);is space, formfeed, newline, carriage return, tab, vertical tabint isupper(int c);is upper-case letterint is xdigit(int c);is hexadecimal digitint tolower(int c);return lower-case equivalentint toupper(int c);return upper-case equivalent[编辑本段]<errno.h>errnoobject to which certain library functions assign specific positive values on errorEDOMcode used for domain errorsERANGEcode used for range errorsNotes:other implementation-defined error values are permittedto determine the value (if any) assigned to errno by a library function, a program sho uld assign zero to errno immediately prior to the function call[编辑本段]<float.h>FLT_RADIXradix of floating-point representationsFLT_ROUNDSfloating-point rounding modeWhere the prefix "FLT" pertains to type float, "DBL" to type double, and "LDBL" to ty pe long double:FLT_DIGDBL_DIGLDBL_DIGprecision (in decimal digits)FLT_EPSILONDBL_EPSILONLDBL_EPSILONsmallest number x such that 1.0 + x != 1.0FLT_MANT_DIGDBL_MANT_DIGLDBL_MANT_DIGnumber of digits, base FLT_RADIX, in mantissaFLT_MAXDBL_MAXLDBL_MAXmaximum numberFLT_MAX_EXPDBL_MAX_EXPLDBL_MAX_EXPlargest positive integer exponent to which FLT_RADIX can be raised and remain repr esentableFLT_MINDBL_MINLDBL_MINminimum normalised numberFLT_MIN_EXPDBL_MIN_EXPLDBL_MIN_EXPsmallest negative integer exponent to which FLT_RADIX can be raised and remain re presentable[编辑本段]<limits.h>CHAR_BITnumber of bits in a charCHAR_MAXmaximum value of type charCHAR_MINminimum value of type charSCHAR_MAXmaximum value of type signed charSCHAR_MINminimum value of type signed charUCHAR_MAXmaximum value of type unsigned charSHRT_MAXmaximum value of type shortSHRT_MINminimum value of type shortUSHRT_MAXmaximum value of type unsigned shortINT_MAXmaximum value of type intINT_MINminimum value of type intUINT_MAXmaximum value of type unsigned intLONG_MAXmaximum value of type longLONG_MINminimum value of type longULONG_MAXmaximum value of type unsigned long[编辑本段]<locale.h>struct lconvDescribes formatting of monetary and other numeric values:char* decimal_point;decimal point for non-monetary valueschar* grouping;sizes of digit groups for non-monetary valueschar* thousands_sep;separator for digit groups for non-monetary values (left of "decimal point") char* currency_s ymbol;currency s ymbolchar* int_curr_s ymbol;international currency s ymbolchar* mon_decimal_point;decimal point for monetary valueschar* mon_grouping;sizes of digit groups for monetary valueschar* mon_thousands_sep;separator for digit groups for monetary values (left of "decimal point")char* negative_sign;negative sign for monetary valueschar* positive_sign;positive sign for monetary valueschar frac_digits;number of digits to be displayed to right of "decimal point" for monetary valueschar int_frac_digits;number of digits to be displayed to right of "decimal point" for international monetary valueschar n_cs_precedes;whether currency s ymbol precedes(1) or follows (0) negative monetary valueschar n_sep_by_space;whether currency s ymbol is (1) or is not (0) separated by space from negative monet ary valueschar n_sign_posn;format for negative monetary values:parentheses surround quantity and currency s ymbol1sign precedes quantity and currency s ymbol2sign follows quantity and currency s ymbol3sign immediately precedes currency s ymbol4sign immediately follows currency s ymbolchar p_cs_precedes;whether currency s ymbol precedes(1) or follows (0) positive monetary valueschar p_sep_by_space;whether currency s ymbol is (1) or is not (0) separated by space from non-negative m onetary valueschar p_sign_posn;format for non-negative monetary values, with values as for n_sign_posnImplementations may change field order and include additional fields. Standard C Libr ary functions use only decimal_point.struct lconv* localeconv(void);returns pointer to formatting information for current localechar* setlocale(int category, const char* locale);Sets components of locale according to specified category and locale. Returns string describing new locale or null on error. (Implementations are permitted to define values of category additional to those describe here.)LC_ALLcategory argument for all categoriesLC_NUMERICcategory for numeric formatting informationLC_MONETARYcategory for monetary formatting informationLC_COLLATEcategory for information affecting collating functionsLC_CTYPEcategory for information affecting character class tes ts functionsLC_TIMEcategory for information affecting time conve rsions functionsNULLnull pointer constant[编辑本段]<math.h>On domain error, implementation-defined value returned and errno set to EDOM. On r ange error, errno set to ERANGE and return value is HUGE_VAL with correct sign for ov erflow, or zero for underflow. Angles are in radians.HUGE_VALmagnitude returned (with correct sign) on overflow errordouble exp(double x);exponential of xdouble log(double x);natural logarithm of xdouble log10(double x);base-10 logarithm of xdouble pow(double x, double y);x raised to power ydouble sqrt(double x);square root of xdouble ceil(double x);smallest integer not less than xdouble floor(double x);largest integer not greater than xdouble fabs(double x);absolute value of xdouble ldexp(double x, int n);x times 2 to the power ndouble frexp(double x, int* exp);if x non-zero, returns value, with absolute value in interval [1/2, 1), and assigns to *e xp integer such that product of return value and 2 raised to the power *exp equals x; if x zero, both return value and *exp are zerodouble modf(double x, double* ip);returns fractional part and assigns to *ip integral part of x,both with same sign as x double fmod(double x, double y);if y non-zero, floating-point remainder of x/y, with same sign as x; if y zero, result is implementation-defineddouble sin(double x);sine of xdouble cos(double x);cosine of xdouble tan(double x);tangent of xdouble asin(double x);arc-sine of xdouble acos(double x);arc-cosine of xdouble atan(double x);arc-tangent of xdouble atan2(double y, double x);arc-tangent of y/xdouble sinh(double x);hyperbolic sine of xdouble cosh(double x);hyperbolic cosine of xdouble tanh(double x);hyperbolic tangent of x[编辑本段]<setjmp.h>jmp_buftype of object holding conte xt informationint setjmp(jmp_buf env);Saves context information in env and returns zero. Subsequent call to longjmp with s ame env returns non-zero.void longjmp(jmp_buf env, int val);Restores context saved by most recent call to setjmp with specified env. Execution re sumes as a second return from setjmp, with returned value val if specified value non-zero, or 1 otherwise.[编辑本段]<signal.h>SIGABRTabnormal terminationSIGFPEarithmetic errorSIGILLinvalid executionSIGINT(as ynchronous) interactive attentionSIGSEGVillegal storage accessSIGTERM(as ynchronous) termination requestSIG_DFLspecifies default signal handlingSIG_ERRsignal return value indicating errorSIG_IGNspecifies that signal should be ignoredvoid (*signal(int sig, void (*handler)(int)))(int);Ins tall handler for subsequent signal sig. If handler is SIG_DFL, implementation-define d default behaviour will be used; if SIG_IGN, signal will be ignored; otherwise function poi nted to by handler will be invoked with argument sig. In the las t case, handling is restored to default behaviour before handler is called. If handler returns, execution resumes where signal occurred. signal returns the previous handler or SIG_ERR on error. Initial state is implementation-defined. Implementations may may define signals additional to those listed here.int raise(int sig);Sends signal sig. Returns zero on success.[编辑本段]<stdarg.h>va_listtype of object holding context informationvoid va_start(va_list ap, lastarg);Initialisation macro which must be called once before any unnamed argument is acces sed. Stores context information in ap. lastarg is the last named parameter of the function.type va_arg(va_list ap, type);Yields value of the type (type) and value of the next unnamed argument.void va_end(va_list ap);Termination macro which must be called once after argument processing and before e xit from function.[编辑本段]<stddef.h>NULLNull pointer constant.offsetof(stype, m)Offset (in bytes) of member m from start of structure type stype.ptrdiff_tType for objects declared to store result of subtracting pointers.Type for objects declared to store result of sizeof operator.[编辑本段]<stdio.h>BUFSIZSize of buffer used by setbuf.EOFValue used to indicate end-of-s tream or to report an error.FILENAME_MAXMaximum length required for array of ch aracters to hold a filename.FOPEN_MAXMaximum number of files which may be open simultaneously.L_tmpnamNumber of characters required for temporary filename generated by tmpnam.NULLNull pointer constant.SEEK_CURValue for origin argument to fseek specifying current file position.SEEK_ENDValue for origin argument to fseek specifying end of file.SEEK_SETValue for origin argument to fseek specifying beginning of file.TMP_MAXMinimum number of unique filenames generated by calls to tmpnam._IOFBFValue for mode argument to setvbuf specifying full buffering._IOLBFValue for mode argument to setvbuf specifying line buffering._IONBFValue for mode argument to setvbuf specifying no buffering.stdinFile pointer for standard input stream. Automatically opened when program execution begins.stdoutFile pointer for standard output stream. Automatically opened when program execution begins.stderrFile pointer for standard error stream. Automatically opened when program execution begins.FILEType of object holding information necessary to control a stream.fpos_tType for objects declared to store file position information.Type for objects declared to store result of sizeof operator.FILE* fopen(cons t char* filename, const char* mode);Opens file named filename and returns a stream, or NULL on failure. mode may be one of the following for text files:"r"text reading"w"text writing"a"text append"r+"text update (reading and writing)"w+"text update, discarding previous content (if any)"a+"text append, reading, and writing at endor one of those strings with b included (after the first character), for binary files.FILE* freopen(const char* filename, cons t char* mode, FILE* stream);Closes file associated with stream, then opens file filename with specified mode and associates it with stream. Returns stream or NULL on error.int fflush(FILE* stream);Flushes stream stream and returns zero on success or EOF on error. Effect undefine d for input stream. fflush(NULL) flushes all output streams.int fclose(FILE* stream);Closes stream s tream (after flushing, if output stream). Returns EOF on error,zero ot herwise.int remove(const char* filename);Removes specified file. Returns non-zero on failure.int rename(cons t char* oldname, const char* newname);Changes name of file oldname to newname. Returns non-zero on failure.FILE* tmpfile();Creates temporary file (mode "wb+") which will be removed when closed or on normal program termination. Returns stream or NULL on failure.char* tmpnam(char s[L_tmpnam]);Assigns to s (if s non-null) and returns unique name for a temporary file. Unique na me is returned for each of the first TMP_MAX invocations.int setvbuf(FILE* stream, char* buf, int mode, size_t size);Controls buffering for s tream s tream. mode is _IOFBF for full buffering, _IOLBF for lin e buffering, _IONBF for no buffe ring. Non-null buf specifies buffer of size size to be used; otherwise, a buffer is allocated. Returns non-zero on error. Call must be before any othe r operation on stream.void setbuf(FILE* s tream, char* buf);Controls buffering for s tream s tream. For null buf, turns off buffering, otherwise equiva lent to (void)setvbuf(stream, buf, _IOFBF, BUFSIZ).int fprintf(FILE* stream, const char* format, ...);Converts(according to format format) and writes output to stream stream. Number of characters written, or negative value on error, is returned. Conversion specifications consis t of:%(optional) flag:-left adjust+always signspacespace if no signzero pad#Alternate form: for conversion character o, firs t di git will be zero, for [xX], prefix 0x o r 0X to non-zero value, for [eEfgG], always decimal point, for [gG] trailing zeros not remo ved.(optional) minimum width: if specified as *, value taken from next argument (which mu st be int).(optional) . (separating width from precision):(optional) precision: for conversion character s, maximum characters to be printed fro m the string, for [eEf], digits after decimal point, for [gG], significant digits, for an integer, minimum number of digits to be printed. If specified as *, value taken from next argume nt (which must be int).(optional) length modifier:hshort or unsigned shortllong or unsigned longLlong doubleconversion character:d,iint argument, printed in signed decim al notationoint argument, printed in unsigned octal notationx,Xint argument, printed in unsigned hexadecimal notationuint argument, printed in unsigned decimal notationcint argument, printed as single characterschar* argumentfdouble argument, printed with format [-]mmm.ddde,Edouble argument, printed with format [-]m.dddddd(e|E)(+|-)xxg,Gdouble argumentpvoid* argument, printed as pointernint* argument : the number of characters written to this point is written into argument%no argument; prints%int printf(const char* format, ...);printf(f, ...) is equivalent to fprintf(s tdout, f, ...)int sprintf(char* s, const char* format, ...);Like fprintf, but output wri tten into s tring s, which must be large enough to hold the output, rather than to a stream. Output is NUL-terminated. Returns length (excluding the t erminating NUL).int vfprintf(FILE* stream, const char* format, va_lis t arg);Equivalent to fprintf with variable argument lis t replaced by arg, which must have bee n initialised by the va_start macro (and may have been used in calls to va_arg).int vprintf(const char* format, va_list arg);Equivalent to printf with variable argument list replaced by arg, which must have been initialised by the va_start macro (and may have been used in calls to va_arg).int vsprintf(char* s, const char* format, va_list arg);Equivalent to sprintf with variable argument list replaced by arg, which must have bee n initialised by the va_start macro (and may have been used in calls to va_arg).int fscanf(FILE* stream, const char* format, ...);Performs formatted input conversion, reading from stream stream according to format f ormat. The function returns when format is fully processed. Returns number of items conv erted and assigned, or EOF if end-of-file or error occurs before any conversion. Each of t he arguments following format must be a pointer. Format string may contain: blanks and tabs, which are ignoredordinary characters, which are expected to match next non-white-space of inputconversion specifications, consisting of:%(optional) assignment suppression character "*"(optional) maximum field width(optional) target width indicator:hargument is pointer to short rather than intlargument is pointer to long rather than int, or double rather than floatLargument is pointer to long double rather than floatconversion character:ddecimal integer; int* parameter requirediinteger; int* parameter required; decimal, octal or hexooctal integer; int* parameter requireduunsigned decimal integer; unsigned int* parameter requiredxhexadecimal integer; int* parameter requiredccharacters; char* parameter required; white-space is not skipped, and NUL-termination is not performedsstring of non-white-space; char* parameter required; string is NUL-terminatede,f,gfloating-point number; float* parameter requiredppointer value; void* parameter requirednchars read so far; int* parameter required[...]longest non-empty string from specified set; char* parameter required; string is NUL-te rminated[^...]longest non-empty string not from specified set; char* parameter required; string is N UL-terminated%literal %; no assignmentint scanf(const char* format, ...);scanf(f, ...) is equivalent to fscanf(stdin, f, ...)int sscanf(char* s, const char* format, ...);Like fscanf, but input read from s tring s.int fgetc(FILE* stream);Returns next character from (input) stream stream, or EOF on end-of-file or error.char* fgets(char* s, int n, FILE* stream);Copies characters from (input) stream stream to s, s topping when n-1 characters copi ed, newline copied, end-of-file reached or error occurs. If no error, s is NUL-terminated. Returns NULL on end-of-file or error, s otherwise.int fputc(int c, FILE* stream);Writes c, to s tream stream. Returns c, or EOF on error.char* fputs(cons t char* s, FILE* stream);Writes s, to (output) stream stream. Returns non-negative on success or EOF on erro r.int getc(FILE* stream);Equivalent to fgetc except that it may be a macro.int getchar(void);Equivalent to getc(stdin).char* gets(char* s);Copies characters from s tdin into s until newline encountered, end-of-file reached, or error occurs. Does not copy newline. NUL-terminates s. Returns s, or NULL on end-of-file or error. Should not be used because of the potential for buffer overflow.int putc(int c, FILE* s tream);Equivalent to fputc except that it may be a macro.int putchar(int c);putchar(c) is equivalent to putc(c, stdout).int puts(const char* s);Writes s (excluding terminating NUL) and a newline to s tdout. Returns non-negative o n success, EOF on error.int ungetc(int c, FILE* stream);Pushes c (which must not be EOF), onto (input) stream stream such that it will be re turned by the next read. Only one character of pushback is guarantee d (for each stream). Returns c, or EOF on error.size_t fread(void* ptr, size_t size, size_t nobj, FILE* s tream);Reads (at most) nobj objects of size size from stream stream into ptr and returns nu mber of objects read. (feof and ferror can be used t o check s tatus.)size_t fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream);Writes to s tream stream, nobj objects of size size from array ptr. Returns number of objects written.int fseek(FILE* stream, long offset, int origin);Sets file position for stream stream and clears end-of-file indicator. For a binary strea m, file position is set to offset bytes from the position indicated by origin: beginning of fil e for SEEK_SET, current position for SEEK_CUR, or end of file for SEEK_END.Behaviou r is similar for a text s tream, but offset must be zero or, for SEEK_SET only, a value ret urned by ftell. Returns non-zero on error.long ftell(FILE* stream);Returns current file position for s tream stream, or -1 on error.void rewind(FILE* stream);Equivalent to fseek(stream, 0L, SEEK_SET); clearerr(stream).int fgetpos(FILE* stream, fpos_t* ptr);Stores current file position for stream stream in *ptr. Returns non-zero on error.int fsetpos(FILE* stream, const fpos_t* ptr);Sets current position of stream stream to *ptr. Returns non-zero on error.void clearerr(FILE* stream);Clears end-of-file and error indicators for s tream s tream.int feof(FILE* stream);Returns non-zero if end-of-file indicator is set for stream stream.int ferror(FILE* stream);Returns non-zero if error indicator is set for stream s tream.void perror(cons t char* s);Prints s (if non-null) and strerror(errno) to standard error as would:fprintf(stderr, "%s: %s\n", (s != NULL ? s : ""), strerror(errno))[编辑本段]<stdlib.h>EXIT_FAILUREValue for status argument to exit indicating failure.EXIT_SUCCESSValue for status argument to exit indicating success.RAND_MAXMaximum value returned by rand().NULLNull pointer constant.div_tReturn type of div(). Structure having members:int quot;quotientint rem;remainderldiv_tReturn type of ldiv(). Structure having members:long quot;quotientlong rem;remaindersize_tType for objects declared to store result of sizeof operator.int abs(int n);long labs(long n);Returns absolute value of n.div_t div(int num, int denom);ldiv_t ldiv(long num, long denom);Returns quotient and remainder of num/denom.double atof(cons t char* s);Equivalent to strtod(s, (char**)NULL) except that errno is not necessarily set on conve rsion error.int atoi(const char* s);Equivalent to (int)strtol(s, (char**)NULL, 10) except that errno is not necessarily set o n conversion error.long atol(const char* s);Equivalent to strtol(s, (char**)NULL, 10) except that errno is not necessarily set on co nversion error.double strtod(const char* s, char** endp);Converts initial characters (ignoring leading white space) of s to type double. If endp non-null, s tores pointer to unconverted suffix in *endp. On overflow, sets errno to ERANG E and returns HUGE_VAL with the appropriate sign; on underflow, sets errno to ERANGE and returns zero; otherwise returns converted value.long strtol(const char* s, char** endp, int base);Converts initial characters (ignoring leading white space) of s to type long. If endp no n-nu ll, stores pointer to unconverted suffix in *endp. If base between 2 and 36, that bas e used for conversion; if zero, leading (after any sign) 0X or 0x implies hexadecimal, lea ding 0 (after any sign) implies octal, otherwise decimal assumed. Leading 0X or 0x permit ted for base hexadecimal. On overflow, sets errno to ERANGE and returns LONG_MAX or LONG_MIN (as appropriate for sign); otherwise returns converted value.unsigned long s trtoul(const char* s, char** endp, int base);As for strtol except result is unsigned long and value on overflow is ULONG_MAX.void* calloc(size_t nobj, size_t size);Returns pointer to zero-initialised newly-allocated space for an array of nobj objects e ach of size size, or NULL on error.void* malloc(size_t size);Returns pointer to uninitialised newly-allocated space for an object of size size, or NU LL on error.void* realloc(void* p, size_t size);Returns pointer to newly-allocated space for an object of size size, initialised, to mini mum of old and new sizes, to exis ting contents of p (if non-null), or NULL on error. On success, old object deallocated, otherwise unchanged.void free(void* p);If p non-null, deallocates space to which it points.void abort();Terminates program abnormally, by calling raise(SIGABRT).void exit(int s tatus);Terminates program normally. Functions ins talled using atexit are called (in reverse or der to that in which installed), open files are flushed, open streams are closed and contro l is returned to environment. s tatus is returned to environment in imp lementation-dependen t manner. Zero or EXIT_SUCCESS indicates successful termination and EXIT_FAILURE in dicates unsuccessful termination. Implementations may define other values.int atexit(void (*fcm)(void));Registers fcn to be called when program terminates normally (or when main returns). Returns non-zero on failure.int s ystem(const char* s);If s is not NULL, passes s to environment for execution, and returns status reported by command processor; if s is NULL, non-zero returned if environment has a command pr ocessor.char* getenv(const char* name);Returns string associated with name name from implementation's environment, or NUL L if no such string exists.void* bsearch(const void* key, const void* base, size_t n, size_t size, int (*cmp)(const void* keyval, const void* datum));Searches ordered array base (of n objects each of size size) for item matching key a ccording to comparison function cmp. cmp must return negative value if first argument is l ess than second, zero if equal and positive if greater. Items of base are assumed to be i n ascending order (according to cmp). Returns a pointer to an item matching key, or NUL L if none found.void qsort(void* base, size_t n, size_t size, int (*cmp)(cons t void*, const void*));Arranges into ascending order array base (of n objects each of size size) according t o comparison function cmp. cmp must return negative value if first argument is less than second, zero if equal and positive if greater.int rand(void);Returns pseudo-random number in range 0 to RAND_MAX.void srand(unsigned int seed);Uses seed as seed for new sequence of pseudo-random numbers. Initial seed is 1. [编辑本段]<string.h>NULLNull pointer constant.size_tType for objects declared to store result of sizeof operator.char* s trcpy(char* s, const char* ct);Copies ct to s including terminating NUL and returns s.char* s trncpy(char* s, const char* ct, size_t n);Copies at most n characters of ct to s. Pads with NUL characters if ct is of length l ess than n. Note that this may leave s without NUL-termination. Return s.char* s trcat(char* s, const char* ct);Concatenate ct to s and return s.char* s trncat(char* s, cons t char* ct, size_t n);Concatenate at most n characters of ct to s. NUL-terminates s and return it.int strcmp(const char* cs, const char* ct);Compares cs with ct, returning negative value if cs<ct, zero if cs==ct, positive value i f cs>ct.int strncmp(const char* cs, cons t char* ct, size_t n);。