‘壹’ 求c语言库函数大全!请大家帮忙!谢了!
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是作废字符(0x7F)或普通控制字符(0x00-0x1F)
返回非0值,否则返回0
int isdigit(int ch) 若ch是数字('0'-'9')返回非0值,否则返回0
int isgraph(int ch) 若ch是可打印字符(不含空格)(0x21-0x7E)返回非0值,否则返回0
int islower(int ch) 若ch是小写字母('a'-'z')返回非0值,否则返回0
int isprint(int ch) 若ch是可打印字符(含空格)(0x20-0x7E)返回非0值,否则返回0
int ispunct(int ch) 若ch是标点字符(0x00-0x1F)返回非0值,否则返回0
int 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')返回相应的大写字母('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中
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+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转换成字符串并返回该字符串
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转换成双精度数,并返回这个数,错误返回0
int atoi(char *nptr) 将字符串nptr转换成整型数, 并返回这个数,错误返回0
long 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() 返回浮点状态字
============目录函数(原型声明所在头文件为dir.h、dos.h)================
int chdir(char *path) 使指定的目录path(如:"C:\\WPS")变成当前的工作目录,成
功返回0
int findfirst(char *pathname,struct ffblk *ffblk,int attrib)查找指定的文件,成功
返回0
pathname为指定的目录名和文件名,如"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_HIDDEN 隐藏文件┃FA_DIREC 目录 ┃
┃FA_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、\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 保存指定驱动器当前工作路径的变量 成功返回0
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 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() 此函数通过调用具有出口代码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,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 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 *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 *pathname,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时, 函数传递的参数个数固定.
v时, 函数传递的参数个数不固定.
e时, 指定参数envp可以传递给子程序,允许改变子程序运行环境.
当无后缀e时,子程序使用本程序的环境.
int system(char *command) 将MSDOS命令command传递给DOS执行
======转换子程序(函数原型所在头文件为math.h、stdlib.h、ctype.h、float.h)========
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转换成双精度数,并返回这个数,错误返回0
int atoi(char *nptr) 将字符串nptr转换成整型数, 并返回这个数,错误返回0
long atol(char *nptr) 将字符串nptr转换成长整型数,并返回这个数,错误返回0
double strtod(char *str,char **endptr)将字符串str转换成双精度数,并返回这个数,
long strtol(char *str,char **endptr,int base)将字符串str转换成长整型数,
并返回这个数,
int toascii(int c) 返回c相应的ASCII
int tolower(int ch) 若ch是大写字母('A'-'Z')返回相应的小写字母('a'-'z')
int _tolower(int ch) 返回ch相应的小写字母('a'-'z')
int toupper(int ch) 若ch是小写字母('a'-'z')返回相应的大写字母('A'-'Z')
int _toupper(int ch) 返回ch相应的大写字母('A'-'Z')
‘贰’ c语言数学函数库怎么用
摘要 调用数学函数时,要求在源文件中包下以下命令行:#include
‘叁’ c语言标准函数库的介绍
在C语言程序设计里,C 标准函数(C Standard library)是所有目前符合标准的头文件(head file)的集合,以及常用的函数库实现程序,例如 I/O输入输出和字串符控制。不像 COBOL、Forrian和 PL/I等编程语言,在 C 语言的工作任务里不会包含嵌入的关键字,所以几乎所有的 C 语言程序都是由标准函数库的函数来创建的。
‘肆’ c语言他对应的函数库是什么
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是作废字符(0x7F)或普通控制字符(0x00-0x1F)
返回非0值,否则返回0
int isdigit(int ch) 若ch是数字('0'-'9')返回非0值,否则返回0
int isgraph(int ch) 若ch是可打印字符(不含空格)(0x21-0x7E)返回非0值,否则返回0
int islower(int ch) 若ch是小写字母('a'-'z')返回非0值,否则返回0
int isprint(int ch) 若ch是可打印字符(含空格)(0x20-0x7E)返回非0值,否则返回0
int ispunct(int ch) 若ch是标点字符(0x00-0x1F)返回非0值,否则返回0
int 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')返回相应的大写字母('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中
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+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转换成字符串并返回该字符串
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转换成双精度数,并返回这个数,错误返回0
int atoi(char *nptr) 将字符串nptr转换成整型数, 并返回这个数,错误返回0
long atol(char *nptr) 将字符串nptr转换成长整型数,并返回这个数,错误返回0
double strtod(char *str,char **endptr)将字符串str转换成双精度数,并返回这个数,
long strtol(char *str,char **endptr,int base)将字符串str转换成长整型数,
‘伍’ c语言的图形函数库有哪些
图形和图像函数包含在graphics.h里面
(一) 像素函数
56. putpiel() 画像素点函数
57. getpixel()返回像素色函数
(二) 直线和线型函数
58. line() 画线函数
59. lineto() 画线函数
60. linerel() 相对画线函数
61. setlinestyle() 设置线型函数
62. getlinesettings() 获取线型设置函数
63. setwritemode() 设置画线模式函数
(三)、多边形函数
64. rectangle() 画矩形函数
65. bar() 画条函数
66. bar3d() 画条块函数
67. drawpoly() 画多边形函数
(四)、 圆、弧和曲线函数
68. getaspectratio()获取纵横比函数
69. circle()画圆函数
70. arc() 画圆弧函数
71. ellipse()画椭圆弧函数
72. fillellipse() 画椭圆区函数
73. pieslice() 画扇区函数
74. sector() 画椭圆扇区函数
75. getarccoords()获取圆弧坐标函数
(五)、 填充函数
76. setfillstyle() 设置填充图样和颜色函数
77. setfillpattern() 设置用户图样函数
78. floodfill() 填充闭域函数
79. fillpoly() 填充多边形函数
80. getfillsettings() 获取填充设置函数
81. getfillpattern() 获取用户图样设置函数
(六)、图像函数
82. imagesize() 图像存储大小函数
83. getimage() 保存图像函数
84. putimage() 输出图像函数
四、图形和图像函数
对许多图形应用程序,直线和曲线是非常有用的。但对有些图形只能靠操作单个像素才能画出。当然如果没有画像素的功能,就无法操作直线和曲线的函数。而且通过大规模使用像素功能,整个图形就可以保存、写、擦除和与屏幕上的原有图形进行叠加。
(一) 像素函数
56. putpixel() 画像素点函数
功能: 函数putpixel() 在图形模式下屏幕上画一个像素点。
用法: 函数调用方式为void putpixel(int x,int y,int color);
说明: 参数x,y为像素点的坐标,color是该像素点的颜色,它可以是颜色符号名,也可以是整型色彩值。
此函数相应的头文件是graphics.h
返回值: 无
例: 在屏幕上(6,8)处画一个红色像素点:
putpixel(6,8,RED);
57. getpixel()返回像素色函数
功能: 函数getpixel()返回像素点颜色值。
用法: 该函数调用方式为int getpixel(int x,int y);
说明: 参数x,y为像素点坐标。
函数的返回值可以不反映实际彩色值,这取决于调色板的设置情况(参见setpalette()函数)。
这个函数相应的头文件为graphics.h
返回值: 返回一个像素点色彩值。
例: 把屏幕上(8,6)点的像素颜色值赋给变量color。
color=getpixel(8,6);
‘陆’ C语言库函数有哪些,怎么用
C语言有好几百个库函数,使用方法:
用#include命令将包含要使用的库函数的头文件包含到自己的程序,然后根据函数原型写出调用语句或表达式。
‘柒’ C语言:如何自己做库函数
简单的一个例子,但是基本的程序编译的思想都在里面了,具体的需要你自己体会和查资料
跟着下面的步骤走
------------------------
第一步:我的电脑-属性-高级-环境变量
添加3个变量
1.名字:path 值:vc的安装目录里面包含cl.exe的bin目录路径+";"+vc目录下包含mspdb80.dll的目录的路径
比如我的是D:\Program Files\Microsoft Visual Studio 8\VC\bin;D:\Program Files\Microsoft Visual Studio 8\Common7\IDE;
2.名字:include 值:vc安装目录下的include目录,主要是为了找到头文件,我的是D:\Program Files\Microsoft Visual Studio 8\VC\include;D:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include;
3.名字:lib 值:vc目录下包含库文件的目录路径
我的是D:\Program Files\Microsoft Visual Studio 8\VC\lib;D:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib;
第二步:需要下面两个文件
//-------------libdemo.c
#include <stdio.h>
void lib_func()
{
printf("this routine in lib\n");
}
//------------main.c
void lib_func();
int main(int argc, char *argv[])
{
lib_func();
}
第三步:命令
cl /c libdemo.c '编译libdemo.c 生成libdemo.obj
lib libdemo.obj '生成libdemo.lib 库文件
cl /c main.c '编译main.c
link main.obj libdemo.lib '生成main.exe
---------------------------------------------------
呵呵 加点东西,参看4楼的建议,在做个dll,COM组件就不做了,有点复杂了
1。把libdemo.c 稍微改下
//-------------libdemo.c
#include <stdio.h>
__declspec (dllexport) void lib_func()
{
printf("this routine in lib\n");
}
2。命令
cl /c libdemo.c main.c
link libdemo.obj /dll '生成libdemo.lib
link main.obj libdemo.lib
‘捌’ C语言常用的函数有哪些
C语言库函数,常用库函数有:
1、scanf格式输入函数
2、printf格式输出函数
3、systemdos命令函数
4、sort排序
5、main主函数
6、fgets文件读取字符串函数
7、fputs文件写入字符串函数
8、fscanf文件格式读取函数
9、fprintf文件格式写入函数
10、fopen打开文件函数
11、getchar输入字符函数
12、putchar输出字符函数
13、malloc动态申请内存函数
14、free释放内存函数
15、abs求绝对值数学函数
16、sqrt求平方根数学函数
(8)c语言在线函数库扩展阅读
语言组成:
1、数据类型
C的数据类型包括:整型、字符型、实型或浮点型(单精度和双精度)、枚举类型、数组类型、结构体类型、共用体类型、指针类型和空类型。
2、常量与变量
常量其值不可改变,符号常量名通常用大写。
变量是以某标识符为名字,其值可以改变的量。标识符是以字母或下划线开头的一串由字母、数字或下划线构成的序列,请注意第一个字符必须为字母或下划线,否则为不合法的变量名。变量在编译时为其分配相应存储单元。
3、数组
如果一个变量名后面跟着一个有数字的中括号,这个声明就是数组声明。字符串也是一种数组。它们以ASCII的NULL作为数组的结束。要特别注意的是,方括内的索引值是从0算起的。
4、指针
如果一个变量声明时在前面使用 * 号,表明这是个指针型变量。换句话说,该变量存储一个地址,而 *(此处特指单目运算符 * ,下同。C语言中另有 双目运算符 *) 则是取内容操作符,意思是取这个内存地址里存储的内容。指针是 C 语言区别于其他同时代高级语言的主要特征之一。
‘玖’ C语言中的头文件有多少种都有哪些C函数库有哪些
iv_t和lldiv_t;宏例如EXIT_FAILURE、EXIT_SUCCESS、RAND_MAX和MB_CUR_MAX等等;
常见的函数有malloc()、calloc()、realloc()、free()、system()、atoi()、atol()、rand()、srand()、exit()等。具体内容可以在编译器的包含目录stdlib.h头文件中打开查看。
为了方便用户编写程序,C语言为用户开发了大量的库函数,定义在。H文件,用户可以调用这些函数来实现强大的功能。因此,对于用户来说,这些函数的使用是提高编程水平的关键。
(9)c语言在线函数库扩展阅读:
以下内容适用于头文件
1.对于具有外部存储类型的标识符,可以在任何其他源程序文件中声明后引用它们,这样用户就可以完全将具有外部存储类型的标识符的一些声明放在头文件中。
2.具体来说,头文件可以包括用户构造的数据类型(例如枚举类型)、外部变量、外部函数、常量和具有一定通用性或公共量的内联函数。一般的变量和函数定义不应该放在头文件中。
其他:
双假设(双x,双y);//给定一个直角三角形的两条边的长度,求斜边的长度。
双ldexp(双x,int指数);//计算x*(2的指数次方)。
双poly(Doublex,intdegree,Doublecoeffs[])//计算多项式。
Ntmatherr(structexception*e)//数学错误计算处理程序。
‘拾’ C 语言标准库函数
C语言标准库函数
标准io函数
Standard C I/O
clearerr() clears errors
fclose() close a file
feof() true if at the end-of-file
ferror() checks for a file error
fflush() writes the contents of the output buffer
fgetc() get a character from a stream
fgetpos() get the file position indicator
fgets() get a string of characters from a stream
fopen() open a file
fprintf() print formatted output to a file
fputc() write a character to a file
fputs() write a string to a file
fread() read from a file
freopen() open an existing stream with a different name
fscanf() read formatted input from a file
fseek() move to a specific location in a file
fsetpos() move to a specific location in a file
ftell() returns the current file position indicator
fwrite() write to a file
getc() read a character from a file
getchar() read a character from STDIN
gets() read a string from STDIN
perror() displays a string version of the current error to STDERR
printf() write formatted output to STDOUT
putc() write a character to a stream
putchar() write a character to STDOUT
puts() write a string to STDOUT
remove() erase a file
rename() rename a file
rewind() move the file position indicator to the beginning of a file
scanf() read formatted input from STDIN
setbuf() set the buffer for a specific stream
setvbuf() set the buffer and size for a specific stream
sprintf() write formatted output to a buffer
sscanf() read formatted input from a buffer
tmpfile() return a pointer to a temporary file
tmpnam() return a unique filename
ungetc() puts a character back into a stream
vprintf, vfprintf, vsprintf write formatted output with variable argument lists
标准字符/字符串处理函数
atof() converts a string to a double
atoi() converts a string to an integer
atol() converts a string to a long
isalnum() true if alphanumeric
isalpha() true if alphabetic
iscntrl() true if control character
isdigit() true if digit
isgraph() true if a graphical character
islower() true if lowercase
isprint() true if a printing character
ispunct() true if punctuation
isspace() true if space
isupper() true if uppercase character
isxdigit() true if a hexidecimal character
memchr() searches an array for the first occurance of a character
memcmp() compares two buffers
memcpy() copies one buffer to another
memmove() moves one buffer to another
memset() fills a buffer with a character
strcat() concatenates two strings
strchr() finds the first occurance of a character in a string
strcmp() compares two strings
strcoll() compares two strings in accordance to the current locale
strcpy() copies one string to another
strcspn() searches one string for any characters in another
strerror() returns a text version of a given error code
strlen() returns the length of a given string
strncat() concatenates a certain amount of characters of two strings
strncmp() compares a certain amount of characters of two strings
strncpy() copies a certain amount of characters from one string to another
strpbrk() finds the first location of any character in one string, in another string
strrchr() finds the last occurance of a character in a string
strspn() returns the length of a substring of characters of a string
strstr() finds the first occurance of a substring of characters
strtod() converts a string to a double
strtok() finds the next token in a string
strtol() converts a string to a long
strtoul() converts a string to an unsigned long
strxfrm() converts a substring so that it can be used by string comparison functions
tolower() converts a character to lowercase
toupper() converts a character to uppercase
标准数学函数
abs() absolute value
acos() arc cosine
asin() arc sine
atan() arc tangent
atan2() arc tangent, using signs to determine quadrants
ceil() the smallest integer not less than a certain value
cos() cosine
cosh() hyperbolic cosine
div() returns the quotient and remainder of a division
exp() returns "e" raised to a given power
fabs() absolute value for floating-point numbers
floor() returns the largest integer not greater than a given value
fmod() returns the remainder of a division
frexp() decomposes a number into scientific notation
labs() absolute value for long integers
ldexp() computes a number in scientific notation
ldiv() returns the quotient and remainder of a division, in long integer form
log() natural logarithm
log10() natural logarithm, in base 10
modf() decomposes a number into integer and fractional parts
pow() returns a given number raised to another number
sin() sine
sinh() hyperbolic sine
sqrt() square root
tan() tangent
tanh() hyperbolic tangent
标准时间/日期函数
asctime() a textual version of the time
clock() returns the amount of time that the program has been running
ctime() returns a specifically formatted version of the time
difftime() the difference between two times
gmtime() returns a pointer to the current Greenwich Mean Time
localtime() returns a pointer to the current time
mktime() returns the calendar version of a given time
strftime() returns indivial elements of the date and time
time() returns the current calendar time of the system
标准内存管理函数
calloc() allocates a two-dimensional chunk of memory
free() makes memory available for future allocation
malloc() allocates memory
realloc() changes the size of previously allocated memory
其它标准函数
abort() stops the program
assert() stops the program if an expression isn';t true
atexit() sets a function to be called when the program exits
bsearch() perform a binary search
exit() stop the program
getenv() get enviornment information about a variable
longjmp() start execution at a certain point in the program
qsort() perform a quicksort
raise() send a signal to the program
rand() returns a pseudorandom number
setjmp() set execution to start at a certain point
signal() register a function as a signal handler
srand() initialize the random number generator
system() perform a system call
va_arg() use variable length parameter lists