2022年C语言库函数大全 .pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年C语言库函数大全 .pdf》由会员分享,可在线阅读,更多相关《2022年C语言库函数大全 .pdf(26页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、c 语言库函数大全 - 资料收集分类函数 ,所在函数库为 ctype.h include “stype.h ”int isalpha(int ch) 若 ch 是字母(A-Z,a-z)返回非 0 值,否则返回 0 int isalnum(int ch) 若 ch 是字母(A-Z,a-z)或数字 (0-9),返回非 0 值,否则返回 0 int isascii(int ch) 若 ch 是字符(ASCII码中的 0-127)返回非 0 值,否则返回 0 int iscntrl(int ch) 若 ch 是作废字符 (0 x7F) 或普通控制字符 (0 x00-0 x1F),返回非 0 值,否则返
2、回 0 int isdigit(int ch) 若 ch 是数字(0-9)返回非 0 值,否则返回 0 int isgraph(int ch) 若 ch 是可打印字符 ( 不含空格 )(0 x21-0 x7E)返回非 0 值,否则返回 0 int islower(int ch) 若 ch 是小写字母 (a-z)返回非 0 值,否则返回 0 int isprint(int ch) 若 ch 是可打印字符 (含空格 )(0 x20-0 x7E)返回非 0 值,否则返回 0 int ispunct(int ch) 若 ch 是标点字符 (0 x00-0 x1F)返回非 0 值,否则返回 0 int
3、isspace(int ch) 若 ch 是空格( ), 水平制表符 (t),回车符 (r), 走纸换行 (f),垂直制表符 (v),换行符(n), 返回非 0 值,否则返回 0 int isupper(int ch) 若 ch 是大写字母 (A-Z)返回非 0 值,否则返回 0 int isxdigit(int ch) 若 ch 是 16 进制数(0-9,A-F,a-f)返回非 0 值, 否则返回 0 int tolower(int ch) 若 ch 是大写字母 (A-Z)返回相应的小写字母 (a-z) int toupper(int ch) 若 ch 是小写字母 (a-z)返回相应的大写字
4、母 (A-Z)数学函数 ,所在函数库为 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 中d
5、ouble ldexp(double value,int exp); 返回 value*2exp的值double log(double x) 返回 logex的值double log10(double x) 返回 log10 x的值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)
6、值,x 为弧度double atan(double x) 返回 x 的反正切 tan-1(x)值,x 为弧度double atan2(double y,double x) 返回 y/x 的反正切 tan-1(x)值,y 的 x 为弧度名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 26 页 - - - - - - - - - double cos(double x) 返回 x 的余弦 cos(x) 值,x 为弧度double sin(double x) 返回 x 的正弦
7、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) 返回不小于
8、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 分成尾数
9、和阶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 转换成字符串并返回
10、该字符串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
11、,int radix) 将整数 value 转换成字符串存入string,radix为转换时所用基数double atof(char *nptr) 将字符串 nptr 转换成双精度数 ,并返回这个数 ,错误返回 0 int atoi(char *nptr) 将字符串 nptr转换成整型数 , 并返回这个数 ,错误返回 0 long atol(char *nptr) 将字符串 nptr转换成长整型数 ,并返回这个数 ,错误返回 0 double strtod(char *str,char *endptr)将字符串 str 转换成双精度数 ,并返回这个数 , long strtol(char *s
12、tr,char *endptr,int base) 将字符串 str 转换成长整型数 , 并返回这个数 , int matherr(struct exception *e) 用户修改数学错误返回信息函数( 没有必要使用 ) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 26 页 - - - - - - - - - double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retva
13、l) 用户修改数学错误返回信息函数(没有必要使用 ) unsigned int _clear87() 清除浮点状态字并返回原来的浮点状态void _fpreset() 重新初使化浮点数学程序包unsigned int _status87() 返回浮点状态字目录函数 ,所在函数库为 dir.h 、dos.h int chdir(char *path) 使指定的目录 path (如:C:WPS)变成当前的工作目录 ,成功返回 0 int findfirst(char *pathname,struct ffblk *ffblk,int attrib)查找指定的文件 ,成功返回 0 pathname为
14、指定的目录名和文件名 ,如C:WPSTXT ffblk 为指定的保存文件信息的一个结构,定义如下 : struct ffblk char ff_reserved21; /*DOS保留字 */ char ff_attrib; /* 文件属性 */ int ff_ftime; /* 文件时间 */ int ff_fdate; /* 文件日期 */ long ff_fsize; /* 文件长度 */ char ff_name13; /* 文件名*/ attrib为文件属性 ,由以下字符代表FA_RDONLY 只读文件 FA_LABEL 卷标号FA_HIDDEN 隐藏文件 FA_DIREC 目录 FA
15、_SYSTEM 系统文件 FA_ARCH 档案 例: struct ffblk ff; findfirst(*.wps,&ff,FA_RDONLY); int findnext(struct ffblk *ffblk) 取匹配 finddirst的文件 ,成功返回 0 void fumerge(char *path,char *drive,char *dir,char *name,char *ext) 此函数通过盘符 drive(C:、A: 等), 路径 dir(TC 、BCLIB等), 文件名 name(TC 、WPS 等),名师资料总结 - - -精品资料欢迎下载 - - - - - -
16、- - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 26 页 - - - - - - - - - 扩展名 ext(.EXE 、.COM 等)组成一个文件名存与path 中. int fnsplit(char *path,char *drive,char *dir,char *name,char *ext) 此函数将文件名 path 分解成盘符 drive(C:、A: 等), 路径 dir(TC 、BCLIB等), 文件名 name(TC 、WPS 等), 扩展名 ext(.EXE 、.COM 等), 并分别存入相应的变量中. int get
17、curdir(int drive,char *direc)此函数返回指定驱动器的当前工作目录名称。成功返回0 drive 指定的驱动器 (0= 当前,1=A,2=B,3=C等) direc 保存指定驱动器当前工作路径的变量char *getcwd(char *buf,iint n) 此函数取当前工作目录并存入buf 中,直到 n 个字节长为为止 .错误返回 NULL int getdisk() 取当前正在使用的驱动器 ,返回一个整数 (0=A,1=B,2=C等) int setdisk(int drive) 设置要使用的驱动器drive(0=A,1=B,2=C等), 返回可使用驱动器总数int
18、 mkdir(char *pathname) 建立一个新的目录 pathname,成功返回 0 int rmdir(char *pathname) 删除一个目录 pathname,成功返回 0 char *mktemp(char *template) 构造一个当前目录上没有的文件名并存于template中char *searchpath(char *pathname) 利用 MSDOS 找出文件 filename所在路径 , 此函数使用 DOS 的 PATH 变量,未找到文件返回 NULL进程函数 ,所在函数库为 stdlib.h 、process.h void abort() 此函数通过调用
19、具有出口代码3 的_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,c
20、har *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 添加
21、到 exec 后,所指定的函数将具有某种操作能力。有后缀p 时,函数可以利用DOS 的 PATH 变量查找子程序文件。名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 26 页 - - - - - - - - - l 时,函数中被传递的参数个数固定。v 时,函数中被传递的参数个数不固定。e 时,函数传递指定参数envp ,允许改变子进程的环境,无后缀e 时,子进程使用当前程序的环境。void _exit(int status) 终止当前程序 ,但不清理现场void exit
22、(int status) 终止当前程序 ,关闭所有文件 ,写缓冲区的输出 (等待输出 ), 并调用任何寄存器的 出口函数 , 无返回值int spawn 运行子程序int spawnl(int mode,char *pathname,char *arg0,char *arg1, , char *argn,NULL) int spawnle(int mode,char *pathname,char *arg0,char *arg1, , char *argn,NULL,char *envp) int spawnlp(int mode,char *pathname,char *arg0,char
23、*arg1, , char *argn,NULL) int spawnlpe(int mode,char *pathname,char *arg0,char *arg1, , char *argn,NULL,char *envp) int spawnv(int mode,char *pathname,char *argv) int spawnve(int mode,char *pathname,char *argv,char *envp) int spawnvp(int mode,char *pathname,char *argv) int spawnvpe(int mode,char *pa
24、thname,char *argv,char *envp) spawn函数族在 mode 模式下运行子程序 pathname,并将参数 arg0(arg1,arg2,argv,envp)传递给子程序 .出错返回 -1 mode为运行模式:mode为 P_WAIT 表示在子程序运行完后返回本程序P_NOWAIT 表示在子程序运行时同时运行本程序( 不可用 ) P_OVERLAY 表示在本程序退出后运行子程序在 spawn 函数族中 ,后缀 l、v、p、e 添加到 spawn后,所指定的函数将具有某种操作能力有后缀p 时, 函数利用 DOS 的 PATH 查找子程序文件l 时, 函数传递的参数个数
25、固定 . v 时, 函数传递的参数个数不固定. e 时, 指定参数 envp 可以传递给子程序 ,允许改变子程序运行环境. 无后缀e 时,子程序使用本程序的环境 . int system(char *command)名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 26 页 - - - - - - - - - 将 MSDOS 命令 command传递给 DOS 执行转换子程序 ,函数库为 math.h、stdlib.h、ctype.h 、float.h char *ecvt
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年C语言库函数大全 2022 语言 库函数 大全
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内