1 字符处理 ctype.h 2 数学函数 math.h 3 输入输出 stdio.h 4 实用工具程序 stdlib.h 5 字符串处理 string.h
程序应包含在math.h |
||||||
函数类型 |
函数形式 |
功能 |
类型 |
|||
数 学 函 数 |
abs(int i) |
求整数的绝对值 |
int |
|||
fabs(double x) |
返回浮点数的绝对值 |
double |
||||
floor(double x) |
向下取整 |
double |
||||
ceil(double x) |
向上取整 |
double |
||||
trunc(double x) |
取整数部分 |
int |
||||
round(double x) |
四舍五入 |
int |
||||
fmod(double x, double y) |
计算x对y的模, 即x/y的余数 |
double |
||||
int(double x) |
取整数部分 |
|
||||
exp(double x) |
指数函数 |
double |
||||
log(double x) |
对数函数ln(x) |
double |
||||
log10(double x) |
对数函数log |
double |
||||
labs(long n) |
取长整型绝对值 |
long |
||||
modf(double value, double *iptr) |
把数分为指数和尾数 |
double |
||||
pow(double x, double y) |
指数函数(x的y次方) |
double |
||||
sqrt(double x) |
计算平方根 |
double |
||||
rand() |
产生0到RAND_MAX之间的随机整数32767 |
int |
||||
sin(double x) |
正弦函数 |
double |
||||
asin(double x) |
反正弦函数 |
double |
||||
sinh(double x) |
双曲正弦函数 |
double |
||||
cos(double x); |
余弦函数 |
double |
||||
acos(double x) |
反余弦函数 |
double |
||||
cosh(double x) |
双曲余弦函数 |
double |
||||
tan(double x) |
正切函数 |
double |
||||
atan(double x) |
反正切函数 |
double |
||||
tanh(double x) |
双曲正切函数 |
double |
||||
程序应包含在ctype.h |
||||||
函数类型 |
函数形式 |
功能 |
类型 |
|||
字 符 函 数 |
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') |
int |
||||
|
|
|
|
|||
程序应包含在string.h |
||||||
函数类型 |
函数形式 |
功能 |
类型 |
|||
字 符 串 函 数 |
strcat(char *dest,const char *src) |
将字符串src添加到dest末尾 |
char |
|||
strchr(const char *s,int c) |
检索并返回字符c在字符串s中第一次出现的位置 |
char |
||||
strcmp(const char *s1,const char *s2) |
比较字符串s1与s2的大小,并返回s1-s2 |
int |
||||
stpcpy(char *dest,const char *src) |
将字符串src复制到dest |
char |
||||
strdup(const char *s) |
将字符串s复制到最近建立的单元 |
char |
||||
strlen(const char *s) |
返回字符串s的长度 |
int |
||||
strlwr(char *s) |
将字符串s中的大写字母全部转换成小写字母,并返回转换后的字符串 |
char |
||||
strrev(char *s) |
将字符串s中的字符全部颠倒顺序重新排列,并返回排列后的字符串 |
char |
||||
strset(char *s,int ch) |
将一个字符串s中的所有字符置于一个给定的字符ch |
char |
||||
strspn(const char *s1,const char *s2) |
扫描字符串s1,并返回在s1和s2中均有的字符个数 |
char |
||||
strstr(const char *s1,const char *s2) |
描字符串s2,并返回第一次出现s1的位置 |
char |
||||
strtok(char *s1,const char *s2) |
检索字符串s1,该字符串s1是由字符串s2中定义的定界符所分隔 |
char |
||||
strupr(char *s) |
将字符串s中的小写字母全部转换成大写字母,并返回转换后的字符串 |
char |
||||
序应包含在stdio.h |
||||||
函数类型 |
函数形式 |
功能 |
类型 |
|||
输
入
输
出
函
数 |
getch() |
从控制台(键盘)读一个字符,不显示在屏幕上 |
int |
|||
putch() |
向控制台(键盘)写一个字符 |
int |
||||
getchar() |
从控制台(键盘)读一个字符,显示在屏幕上 |
int |
||||
putchar() |
向控制台(键盘)写一个字符 |
int |
||||
getc(FILE *stream) |
从流stream中读一个字符,并返回这个字符 |
int |
||||
putc(int ch,FILE *stream) |
向流stream写入一个字符ch |
int |
||||
getw(FILE *stream) |
从流stream读入一个整数,错误返回EOF |
int |
||||
putw(int w,FILE *stream) |
向流stream写入一个整数 |
int |
||||
fclose(handle) |
关闭handle所表示的文件处理 |
FILE * |
||||
fgetc(FILE *stream) |
从流stream处读一个字符,并返回这个字符 |
int |
||||
fputc(int ch,FILE *stream) |
将字符ch写入流stream中 |
int |
||||
fgets(char *string,int n,FILE *stream) |
流stream中读n个字符存入string中 |
c har * |
||||
fopen(char *filename,char *type) |
打开一个文件filename,打开方式为type,并返回这个文件指针,type可为以下字符串加上后缀 |
FILE * |
||||
fputs(char *string,FILE *stream) |
将字符串string写入流stream中 |
int |
||||
fread(void *ptr,int size,int nitems,FILE *stream) |
从流stream中读入nitems个长度为size的字符串存入ptr中 |
int |
||||
fwrite(void *ptr,int size,int nitems,FILE *stream) |
向流stream中写入nitems个长度为size的字符串,字符串在ptr中 |
int |
||||
fscanf(FILE *stream,char *format[,argument,…]) |
以格式化形式从流stream中读入一个字符串 |
int |
||||
fprintf(FILE *stream,char *format[,argument,…]) |
以格式化形式将一个字符串写给指定的流stream |
int |
||||
scanf(char *format[,argument…]) |
从控制台读入一个字符串,分别对各个参数进行赋值,使用BIOS进行输出 |
int |
||||
printf(char *format[,argument,…])
|
发送格式化字符串输出给控制台(显示器),使用BIOS进行输出 |
int |
||||