序号 |
函数原型 |
标准头文件 |
功能 |
返回值 |
1 |
int fclose(FILE *fp) |
<stdio.h> |
关闭fp所指的文件,释放文件缓冲区 |
出错返回非0,否则返回0 |
2 |
int feof (FILE *fp) |
<stdio.h> |
检查文件是否结束 |
遇文件结束返回非0,否则返回0 |
3 |
char *fgets(char *buf,int n, FILE *fp) |
<stdio.h> |
从fp所指的文件中读取一个长度为n-1的字符串,将其存入buf所指存储区 |
返回buf所指地址,若遇文件结束或出错返回NULL |
4 |
FILE *fopen(char *filename,char *mode) |
<stdio.h> |
以mode指定的方式打开名为filename的文件 |
成功,返回文件指针(文件信息区的起始地址),否则返回NULL |
5 |
int fread(char *pt,unsigned size,unsigned n, FILE *fp) |
<stdio.h> |
从fp所指文件中读取长度size为n个数据项存到pt所指文件 |
读取的数据项个数 |
6 |
int fwrite(char *pt,unsigned size,unsigned n, FILE *fp) |
<stdio.h> |
把pt所指向的n*size个字节输入到fp所指文件 |
输出的数据项个数 |
7 |
int printf(char *format,args,…) |
<stdio.h> |
把args,…的值以format指定的格式输出到标准输出设备 |
输出字符的个数 |
8 |
int abs( int x) |
<math.h> |
求整数x的绝对值 |
计算结果 |
9 |
double fabs(double x) |
<math.h> |
求双精度实数x的绝对值 |
计算结果 |
10 |
double pow(double x,double y) |
<math.h> |
计算x的y次幂的值 |
计算结果 |
11 |
double sqrt(double x) |
<math.h> |
计算x的开方 |
计算结果 |
12 |
int isdigit(int ch) |
<ctype.h> |
检查ch是否为数字 |
是,返回1;否则返回0 |
13 |
int islower(int ch) |
<ctype.h> |
检查ch是否为小写字母 |
是,返回1;否则返回0 |
14 |
int isupper(int ch) |
<ctype.h> |
检查ch是否为大写字母 |
是,返回1;否则返回0 |
15 |
int tolower(int ch) |
<ctype.h> |
把ch中的字母转换成小写字母 |
返回对应的小写字母 |
16 |
int toupper(int ch) |
<ctype.h> |
把ch中的字母转换成大写字母 |
返回对应的大写字母 |
17 |
char *strcat(char *s1,char *s2) |
<string.h> |
把字符串s2接到s1后面 |
s1所指地址 |
18 |
char *strchr(char *s,int ch) |
<string.h> |
在s所指字符串中,找出第一次出现字符ch的位置 |
返回找到的字符的地址,找不到返回NULL |
19 |
int strcmp(char *s1,char *s2) |
<string.h> |
对s1和s2所指字符串进行比较 |
s1<s2,返回负数;s1= =s2,返回0;s1>s2,返回正数 |
20 |
char *strcpy(char *s1,char *s2) |
<string.h> |
把s2指向的串复制到s1指向的空间 |
s1 所指地址 |
21 |
unsigned strlen(char *s) |
<string.h> |
求字符串s的长度 |
返回串中字符(不计最后的'\0')个数 |
22 |
char *strstr(char *s1,char *s2) |
<string.h> |
在s1所指字符串中,找出字符串s2第一次出现的位置 |
返回找到的字符串的地址,找不到返回NUL |
23 |
void *free(void *p) |
<stdlib.h> |
释放p所指的内存区 |
无 |
24 |
void *malloc(unsigned size) |
<stdlib.h> |
分配size个字节的存储空间 |
分配内存空间的地址;如不成功,返回0 |
25 |
int rand(void) |
<stdlib.h> |
产生0~32767的随机整数 |
返回一个随机整数 |
26 |
void exit(int state) |
<stdlib.h> |
程序终止执行,返回调用过程,state为0正常终止,非0非正常终止 |
无 |