C语言库函数手册

合集下载

c语言各常用函数,c语言常用函数速查手册pdf

c语言各常用函数,c语言常用函数速查手册pdf

c语⾔各常⽤函数,c语⾔常⽤函数速查⼿册pdfC语⾔常⽤函数速查⼿册是⼀本⾮常全⾯系统的讲述了学习c语⾔相关的常⽤函数,包括常见的350多个常⽤函数,且每⼀个常⽤函数后⾯都会有⼀个经典的⽰例帮助更快掌握C语⾔,欢迎下载。

图书简介:为了⽅便查找,所有函数都按照所在库进⾏分章讲解。

这样既⽅便读者系统学习,也⽅便同类函数的对⽐和查找。

本书所涉及的函数全⾯,适合所有想学习C语⾔的开发⼈员、爱好者和⼤中专院校学⽣使⽤。

对于经常采⽤C语⾔进⾏开发的开发⼈员,更是⼀本不可多得的案头必备⼯具参考书。

C语⾔常⽤函数速查⼿册全⾯、系统地讲解了C语⾔相关的21个函数库,所涉及的函数多达352个。

为了⽅便读者学习,每⼀个函数都依次对其作⽤、语法形式、参数、返回值进⾏了讲解。

同时,每个函数都配有专门的例⼦,供读者参考学习。

最后给出了本书所涉及C语⾔函数的索引,便于读者检索。

图书⽬录:第1章 输⼊输出函数库:stdio.h第2章 数学函数库:math.h第3章 字符函数库:ctype.h第4章 字符串函数库:string.h第5章 标准库函数库:system.h第6章 图形处理函数库:graphics.h第7章 动态内存管理函数库:alloc.h第8章 ⽬录操作函数库:dir.h第9章 系统接⼝函数库:dos.h第10章 输⼊输出函数库:io.h第11章 浮点数据处理库:float.h第12章 控制台输⼊输出函数库:conio.h第13章 DEBUG相关函数库:assert.h第14章 BIOS相关函数库:bios.h第15章 内存相关函数库:mem.h第16章 进程管理函数库:process.h第17章 函数跳转函数库:setjmp.h第18章 信号定义函数库:signal.h第19章 函数参数处理函数库:stdarg.h第20章 时间函数库:time.h第21章 标准⼯具库函数库:stdlib.h附录 索引。

c语言math函数库手册

c语言math函数库手册

函数名称: abs函数原型: int abs(int x);函数功能: 求整数x的绝对值函数返回: 计算结果参数说明:所属文件: <>,<>使用范例:#include <>#include <>int main(){int number=-1234;printf("number: %d absolute value: %d",number,abs(number)); return 0;}@函数名称: fabs函数原型: double fabs(double x);函数功能: 求x的绝对值.函数返回: 计算结果参数说明:所属文件: <>使用范例:#include <>#include <>int main(){float number=;printf("number: %f absolute value: %f",number,fabs(number)); return 0;}@函数名称: cabs函数原型: double cabs(struct complex znum)函数功能: 求复数的绝对值函数返回: 复数的绝对值参数说明: zuum为用结构struct complex表示的复数,定义如下:struct complex{double m;double n;}所属文件: <>#include <>#include <>int main(){struct complex z;double val;=;=;val=cabs(z);printf("The absolute value of %.2lfi %.2lfj is %.2lf",,,val); return 0;}@函数名称: ceil函数原型: double ceil(double num)函数功能: 得到不小于num的最小整数函数返回: 用双精度表示的最小整数参数说明: num-实数所属文件: <>#include <>#include <>int main(){double number=;double down,up;down=floor(number);up=ceil(number);printf("original number %",number);printf("number rounded down %",down);printf("number rounded up %",up);return 0;}@函数名称: sin函数原型: double sin(double x);函数功能: 计算sinx的值.正弦函数函数返回: 计算结果参数说明: 单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result,x=;result=sin(x);printf("The sin() of %lf is %lf",x,result); return 0;}@函数名称: cos函数原型: double cos(double x);函数功能: 计算cos(x)的值.余弦函数.函数返回: 计算结果参数说明: x的单位为弧度所属文件: <>使用范例:#include <>#include <>int main()double result;double x=;result=cos(x);printf("The cosine of %lf is %lf",x,result);return 0;}@函数名称: tan函数原型: double tan(double x);函数功能: 计算tan(x)的值,即计算角度x的正切数值函数返回: 计算结果参数说明: x>=0单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result,x;x=;result=tan(x);printf("The tan of %lf is %lf",x,result);return 0;}@函数名称: asin函数原型: double asin(double x);函数功能: 计算sin^-1(x)的值.反正弦值函数函数返回: 计算结果参数说明: x应在 -1 到 1 范围内.单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=asin(x);printf("The arc sin of %lf is %lf",x,result); return 0;}@函数名称: acos函数原型: double acos(double x);函数功能: 计算cos^-1(x)的值,反余弦函数函数返回: 计算结果参数说明: x应在-1到1范围内.切记单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=acos(x);printf("The arc cosine of %lf is %lf",x,result); return 0;}@函数名称: atan函数原型: double atan(double x);函数功能: 计算tan^-1(x)的值.函数返回: 计算结果参数说明: 单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=atan(x);printf("The arc tangent of %lf is %lf",x,result);return 0;}@函数名称: atan2函数原型: double atan2(double x,double y);函数功能: 计算tan^-1/(x/y)的值.求x/y的反正切值.函数返回: 计算结果参数说明: 单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=,y=;result=atan2(y,x);printf("The arc tangent ratio of %lf is %lf",(y/x),result); return 0;}@函数名称: sinh函数原型: double sinh(double x);函数功能: 计算x的双曲正弦函数sinh(x)的值.函数返回: 计算结果参数说明: 单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result,x=;result=sinh(x);printf("The hyperbolic sin() of %lf is %lf",x,result); return 0;}@函数名称: cosh函数原型: double cosh(double x);函数功能: 计算x的双曲余弦cosh(x)的值.函数返回: 计算结果参数说明:所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=cosh(x);printf("The hyperboic cosine of %lf is %lf",x,result); return 0;}@函数名称: tanh函数原型: double tanh(double x);函数功能: 计算x的双曲正切函数tanh(x)的值.函数返回: 计算结果参数说明: x>=0所属文件: <>使用范例:#include <>#include <>int main(){double result,x;x=;result=tanh(x);printf("The hyperbolic tangent of %lf is %lf",x,result); return 0;}@函数名称: exp函数原型: double exp(double x);函数功能: 求e的x次幂函数返回: 计算结果.幂的值参数说明: x-指数所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=exp(x);printf("'e' raised to the power of %lf(e^%lf)=%lf",x,x,result); return 0;}@函数名称: floor函数原型: double floor(double x);函数功能: 求出不大于x的最大整数.函数返回: 该整数的双精度实数参数说明:所属文件: <>使用范例:#include <>#include <>int main(){double number=;double down,up;down=floor(number);up=ceil(number);printf("original number %",number);printf("number rounded down %",down);printf("number rounded up %",up);return 0;}@函数名称: fmod函数原型: double fmod(double x,double y);函数功能: 求整数x/y的余数函数返回: 返回余数的双精度数.x/y的余数值.参数说明:所属文件: <>使用范例:#include <>#include <>int main(){double x=,y=;double result;result=fmod(x,y);printf("The remainder of (%lf/%lf) is %lf",x,y,result);return 0;}@函数名称: frexp函数原型: double frexp(double val,int *eptr);函数功能: 把双精度数val分解为数字部分(尾数)x和以2为底的指数n,即val=x*2^n,n存放在eptr指向的变量中.函数返回: 返回数字部分x,<=x且x<1参数说明: val-待分解的数所属文件: <>使用范例:#include <>#include <>int main(){double mantissa,number;int exponent;number=;mantissa=frexp(number,&exponent);printf("The number %lf is",number);printf("%lf times two to the",mantissa);printf("power of %d",exponent);return 0;}@函数名称: log函数原型: double log(double x);函数功能: 求logeX(e指的是以e为底),即计算x的自然对数(ln X) 函数返回: 计算结果参数说明:所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=log(x);printf("The natural log of %lf is %lf",x,result);return 0;}@函数名称: log10函数原型: double log10(double x);函数功能: 求log10x(10指的是以10为底).计算x的常用对数函数返回: 计算结果参数说明:所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=log10(x);printf("The common log of %lf is %lf",x,result);return 0;}@函数名称: modf函数原型: double modf(double val,double *iptr);函数功能: 把双精度数val分解为整数部分和小数部分,把整数部分存到iptr指向的单元. 函数返回: val的小数部分参数说明: val 待分解的数所属文件: <>使用范例:#include <>#include <>int main(){double fraction,integer;double number=;fraction=modf(number,&integer);printf("The whole and fractional parts of %lf are %lf and%lf",number,integer,fraction);}@函数名称: pow函数原型: double pow(double x,double y);函数功能: 计算以x为底数的y次幂,即计算x^y的值. 函数返回: 计算结果参数说明: x-底数,y-幂数所属文件: <>使用范例:#include <>#include <>int main(){double x=,y=;printf("%lf raised to %lf is %lf",x,y,pow(x,y)); return 0;}@函数名称: sqrt函数原型: double sqrt(double x);函数功能: 计算x的开平方.函数返回: 计算结果参数说明: x>=0所属文件: <>#include <>#include <>int main(){double x=,result;result=sqrt(x);printf("The square root of %lf is %lf",x,result); return 0;}@函数名称: hypot函数原型: double hypot(double x,double y)函数功能: 已知直角三角形两个直角边长度,求斜边长度函数返回: 斜边长度参数说明: x,y-直角边长度所属文件: <>#include <>#include <>int main(){double result;double x=;double y=;result=hypot(x,y);printf("The hypotenuse is: %lf",result);return 0;}@函数名称: poly函数原型: double poly(double x,int degree,double coeffs[])函数功能: 计算多项式函数返回: 多项式的计算结果参数说明: 计算c[n]*x^n+c[n-1]x^n-1+.....+c[1]*x+c[0]所属文件: <>#include <>#include <>int main(){double array[]={,,,};double result;result=poly,3,array);printf("The polynomial: x**3 - **2 + 5x - 1 at is %lf",result); return 0;}@函数名称: matherr函数原型: int matherr(struct exception *e)函数功能: 数学错误计算处理程序函数返回:参数说明: 该函数不能被直接调用,而是被库函数_matherr()调用所属文件: <>#include<>int matherr(struct exception *a){return 1;}@函数名称: ldexp函数原型: double ldexp(double x,int exponent)函数功能: 计算x*2的exponent次幂,即2*pow(2,exponent)的数值函数返回:参数说明:所属文件: <>#include <>#include <>int main(){double value;double x=2;value=ldexp(x,3);printf("The ldexp value is: %lf",value);return 0;}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) 返回xy的值double pow10(int p) 返回10p的值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+y2double 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转换成字符串并返回该字符串char *gcvt(double value,int ndigit,char *buf)将数value转换成字符串并存于buf中,并返回buf的指针char *ultoa(unsigned long value,char *string,int radix)将无符号整型数value转换成字符串并返回该字符串,radix为转换时所用基数char *ltoa(long value,char *string,int radix)将长整型数value转换成字符串并返回该字符串,radix为转换时所用基数char *itoa(int value,char *string,int radix)将整数value转换成字符串存入string,radix为转换时所用基数double atof(char *nptr) 将字符串nptr转换成双精度数,并返回这个数,错误返回0int atoi(char *nptr) 将字符串nptr转换成整型数, 并返回这个数,错误返回0long atol(char *nptr) 将字符串nptr转换成长整型数,并返回这个数,错误返回0 double strtod(char *str,char **endptr)将字符串str转换成双精度数,并返回这个数, long strtol(char *str,char **endptr,int base)将字符串str转换成长整型数,并返回这个数,int matherr(struct exception *e)用户修改数学错误返回信息函数(没有必要使用)double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retval)用户修改数学错误返回信息函数(没有必要使用)unsigned int _clear87() 清除浮点状态字并返回原来的浮点状态void _fpreset() 重新初使化浮点数学程序包unsigned int _status87() 返回浮点状态字。

C语言常用库函数介绍

C语言常用库函数介绍

C语言常用库函数介绍C语言作为一种功能强大、使用广泛的编程语言,提供了许多常用的库函数来帮助开发者简化编程工作,提高代码的效率和可读性。

本文将介绍C语言中一些常用的库函数,包括字符串相关函数、数学函数、输入输出函数等。

一、字符串相关函数1. strlen函数功能:计算字符串的长度。

用法:size_t strlen(const char *str);示例:```c#include <string.h>#include <stdio.h>int main() {char str[] = "Hello World";int len = strlen(str);printf("字符串长度为:%d", len);return 0;}```这段代码会输出:字符串长度为:11。

2. strcpy函数功能:将一个字符串复制到另一个字符串。

用法:char *strcpy(char *dest, const char *src);示例:```c#include <string.h>#include <stdio.h>int main() {char src[] = "Hello World";char dest[20];strcpy(dest, src);printf("复制后的字符串为:%s", dest);return 0;}```这段代码会输出:复制后的字符串为:Hello World。

3. strcat函数功能:将一个字符串连接到另一个字符串末尾。

用法:char *strcat(char *dest, const char *src);示例:```c#include <string.h>#include <stdio.h>int main() {char str1[30] = "Hello";char str2[] = " World";strcat(str1, str2);printf("连接后的字符串为:%s", str1);return 0;}```这段代码会输出:连接后的字符串为:Hello World。

C语言函数参考手册

C语言函数参考手册

C语言函数参考手册一、概述C语言是一种通用的、面向过程的程序设计语言,广泛应用于系统编程和应用软件开发等领域。

在C语言中,函数是非常重要的组成部分,通过函数可以实现代码的模块化和重复使用。

本手册旨在为C语言开发者提供函数相关信息的参考,包括常用函数的用法、参数说明和返回值等。

二、函数的声明函数声明是指在使用函数之前,需要先声明函数的存在及函数的参数类型和返回值类型。

函数声明通常位于源文件的开头部分,以便在其他代码中使用。

1. 函数声明的一般格式如下:返回值类型函数名(参数列表);2. 示例:int max(int a, int b);void printHello();三、函数的定义函数定义是指实现函数的功能代码,并且包含函数的参数和返回值类型的明确说明。

函数定义通常位于源文件的主体部分。

1. 函数定义的一般格式如下:返回值类型函数名(参数列表) {函数体代码return 返回值;}2. 示例:int max(int a, int b) {if (a > b) {return a;} else {return b;}}void printHello() {printf("Hello, world!\n");}四、函数的参数函数的参数是指在函数的括号内声明的变量,用于接受调用函数时传递的值。

函数的参数可以有多个,也可以没有参数。

1. 参数的声明格式如下:参数类型参数名2. 示例:int add(int a, int b);void printName(char* name);五、函数的返回值函数的返回值是指函数执行完成后返回的结果。

返回值可以是任何数据类型,如整数、浮点数、字符等。

函数的返回值可以有多种情况,根据具体逻辑来确定。

1. 返回值的声明格式如下:返回值类型2. 示例:int max(int a, int b);double calculateAverage(int array[], int length);六、常用函数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语言中扮演着至关重要的角色,可以提供各种各样的功能和方法,帮助我们更高效地编写程序。

本文将为您提供一份C语言库函数的使用指南,帮助您更好地掌握这些常用的函数。

一、输入输出函数1. printf()printf()函数是C语言用于输出信息的常用函数。

它可以按照指定的格式将数据输出到屏幕上。

例如:```c#include<stdio.h>int main(){int num = 10;printf("The number is %d\n", num);return 0;}```2. scanf()scanf()函数是C语言用于从键盘上接收用户输入的函数。

通过指定变量的地址,将用户输入的数据保存到相应的变量中。

例如:```c#include<stdio.h>int main(){int num;printf("Please enter a number: ");scanf("%d", &num);printf("You entered: %d\n", num);return 0;}```二、字符串处理函数1. strlen()strlen()函数用于计算字符串的长度,即该字符串中字符的个数(不包括字符串结束符'\0')。

例如:```c#include<stdio.h>#include<string.h>int main(){char str[] = "Hello, world!";int length = strlen(str);printf("The length of the string is %d\n", length);return 0;}```2. strcpy()和strcat()strcpy()函数用于将一个字符串复制到另一个字符串中。

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语言是一种广泛应用于软件开发领域的编程语言,它提供了许多库函数来方便开发者编写高效且可靠的程序。

本文将为大家介绍一些常用的C语言库函数,以及它们的使用方法和示例代码。

一、stdio.h 库函数1. printf 函数:用于在控制台输出指定格式的数据。

示例代码:```c#include <stdio.h>int main() {int number = 10;printf("The number is %d\n", number);return 0;}```2. scanf 函数:用于从控制台读取输入数据。

示例代码:```c#include <stdio.h>int main() {int number;printf("Please enter a number: ");scanf("%d", &number);printf("You entered: %d\n", number);return 0;}```二、stdlib.h 库函数1. malloc 函数:用于在堆中分配指定大小的内存空间。

示例代码:```c#include <stdlib.h>int main() {int *numbers = (int*) malloc(5 * sizeof(int));for (int i = 0; i < 5; i++) {numbers[i] = i + 1;}for (int i = 0; i < 5; i++) {printf("%d ", numbers[i]);}free(numbers);return 0;}```2. rand 函数:用于生成随机数。

示例代码:```c#include <stdio.h>#include <stdlib.h>#include <time.h>int main() {srand(time(NULL));int randomNumber = rand() % 100;printf("Random number: %d\n", randomNumber);return 0;}```三、string.h 库函数1. strcpy 函数:用于将一个字符串复制到另一个字符串。

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

C语言库函数手册分类函数,所在函数库为 ctype.hint isalpha(int ch) 若ch是字母('A'-'Z','a'-'z')返回非0值,否则返回0 int isalnum(int ch) 若ch是字母('A'-'Z','a'-'z')或数字('0'-'9')返回非0值,否则返回0int isascii(int ch) 若ch是字符(ASCII码中的0-127)返回非0值,否则返回0int iscntrl(int ch) 若ch是作废字符(0x7F)或普通控制字符(0x00-0x1F)返回非0值,否则返回0int isdigit(int ch) 若ch是数字('0'-'9')返回非0值,否则返回0int isgraph(int ch) 若ch是可打印字符(不含空格)(0x21-0x7E)返回非0值,否则返回0int islower(int ch) 若ch是小写字母('a'-'z')返回非0值,否则返回0int isprint(int ch) 若ch是可打印字符(含空格)(0x20-0x7E)返回非0值,否则返回0int ispunct(int ch) 若ch是标点字符(0x00-0x1F)返回非0值,否则返回0 int isspace(int ch) 若ch是空格(' '),水平制表符('\t'),回车符('\r'),走纸换行('\f'),垂直制表符('\v'),换行符('\n')返回非0值,否则返回0int isupper(int ch) 若ch是大写字母('A'-'Z')返回非0值,否则返回0int isxdigit(int ch) 若ch是16进制数('0'-'9','A'-'F','a'-'f')返回非0值,否则返回0int tolower(int ch) 若ch是大写字母('A'-'Z')返回相应的小写字母('a'-'z')int toupper(int ch) 若ch是小写字母('a'-'z')返回相应的大写字母('A'-'Z')数学函数,所在函数库为 math.h、stdlib.h、string.h、float.hint abs(int i) 返回整型参数i的绝对值double cabs(struct complex znum) 返回复数znum的绝对值double fabs(double x) 返回双精度参数x的绝对值long labs(long n) 返回长整型参数n的绝对值double exp(double x) 返回指数函数e^x的值double frexp(double value,int *eptr) 返回value=x*2n中x的值,n存贮在eptr中double ldexp(double value,int exp); 返回value*2exp的值double log(double x) 返回ln(x)的值double log10(double x) 返回log10(x)的值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+y2double 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转换成字符串并返回该字符串char *gcvt(double value,int ndigit,char *buf)将数value转换成字符串并存于buf中,并返回buf的指针char *ultoa(unsigned long value,char *string,int radix)将无符号整型数value转换成字符串并返回该字符串,radix为转换时所用基数char *ltoa(long value,char *string,int radix)将长整型数value转换成字符串并返回该字符串,radix为转换时所用基数char *itoa(int value,char *string,int radix)将整数value转换成字符串存入string,radix为转换时所用基数double atof(char *nptr) 将字符串nptr转换成双精度数,并返回这个数,错误返回0int atoi(char *nptr) 将字符串nptr转换成整型数, 并返回这个数,错误返回0long atol(char *nptr) 将字符串nptr转换成长整型数,并返回这个数,错误返回0double strtod(char *str,char **endptr)将字符串str转换成双精度数,并返回这个数,long strtol(char *str,char **endptr,int base)将字符串str转换成长整型数,并返回这个数,int matherr(struct exception *e)用户修改数学错误返回信息函数(没有必要使用)double _matherr(_mexcep why,char *fun,double *arg1p,double*arg2p,double retval)用户修改数学错误返回信息函数(没有必要使用)unsigned int _clear87() 清除浮点状态字并返回原来的浮点状态void _fpreset() 重新初使化浮点数学程序包unsigned int _status87() 返回浮点状态字目录函数,所在函数库为 dir.h、dos.hint chdir(char *path) 使指定的目录path(如:"C:\\WPS")变成当前的工作目录,成功返回0int findfirst(char *pathname,struct ffblk *ffblk,int attrib)查找指定的文件,成功返回0pathname为指定的目录名和文件名,如"C:\\WPS\\TXT"ffblk为指定的保存文件信息的一个结构,定义如下:┏━━━━━━━━━━━━━━━━━━┓┃struct ffblk ┃┃{ ┃┃ char ff_reserved[21]; /*DOS保留字*/┃┃ char ff_attrib; /*文件属性*/ ┃┃ int ff_ftime; /*文件时间*/ ┃┃ int ff_fdate; /*文件日期*/ ┃┃ long ff_fsize; /*文件长度*/ ┃┃ char ff_name[13]; /*文件名*/ ┃┃} ┃┗━━━━━━━━━━━━━━━━━━┛attrib为文件属性,由以下字符代表┏━━━━━━━━━┳━━━━━━━━┓┃FA_RDONLY 只读文件┃FA_LABEL 卷标号┃┃FA_H IDDEN 隐藏文件┃FA_DIREC 目录┃┃FA_SYSTEM 系统文件┃FA_ARCH 档案┃┗━━━━━━━━━┻━━━━━━━━┛例:struct ffblk ff;findfirst("*.wps",&ff,FA_RDONLY);int findnext(struct ffblk *ffblk) 取匹配finddirst的文件,成功返回0void fumerge(char *path,char *drive,char *dir,char *name,char *ext) 此函数通过盘符drive(C:、A:等),路径dir(\TC、\BC\LIB等),文件名name(TC、WPS等),扩展名ext(.EXE、.COM等)组成一个文件名存与path中.int fnsplit(char *path,char *drive,char *dir,char *name,char *ext) 此函数将文件名path分解成盘符drive(C:、A:等),路径dir(\TC、\BC\LIB等),文件名name(TC、WPS等),扩展名ext(.EXE、.COM等),并分别存入相应的变量中.int getcurdir(int drive,char *direc) 此函数返回指定驱动器的当前工作目录名称drive 指定的驱动器(0=当前,1=A,2=B,3=C等)direc 保存指定驱动器当前工作路径的变量成功返回0char *getcwd(char *buf,iint n) 此函数取当前工作目录并存入buf中,直到n 个字节长为为止.错误返回NULLint getdisk() 取当前正在使用的驱动器,返回一个整数(0=A,1=B,2=C等) int setdisk(int drive) 设置要使用的驱动器drive(0=A,1=B,2=C等), 返回可使用驱动器总数int mkdir(char *pathname) 建立一个新的目录pathname,成功返回0int rmdir(char *pathname) 删除一个目录pathname,成功返回0char *mktemp(char *template) 构造一个当前目录上没有的文件名并存于template中char *searchpath(char *pathname) 利用MSDOS找出文件filename所在路径, ,此函数使用DOS的PATH变量,未找到文件返回NULL进程函数,所在函数库为stdlib.h、process.hvoid abort() 此函数通过调用具有出口代码3的_exit写一个终止信息于stderr,并异常终止程序。

相关文档
最新文档