文件操作函数:
void clearer(FILE *stream);//使文件错误标志和文件结束标志
int fclose(FILE *stream);//关闭一个流,将内存中的数据写到磁盘
int feof(FILE *stream);//检测流上的文件结束符
int ferror(FILE *stream);//检测流上的错
int fgetc(FILE *infile);//从infile所指向的文件中读取
char *fgets(char *buffer, int bufSize, FILE *source);//从source所关联的磁盘文件中读入bufSize-1个字符,最后加一个’\0’结束符
FILE *fopen(const char *filename, const char *mode);//打开一个文件并返回一 个指向该文件的指针
int fprintf(FILE *pTarget, const char *format, argument_list);//argument_list的值以format指定的格式输出到pTarget所指定的文件中
int fputs(const char *buffer, File *destination);//将buffer所指向的字符串写入destination所关联的磁盘文件中,’/0’结束符不输出
int fread(void *buffer, int size, int count, FILE *source);//从source所指向的文件中读取长度为size的count个数据项,存到buffer所指向的内存区
int fscanf(FILE *pSource, const char *format, args, …);//从source所指向的文件中按format指定的格式将输入数据送到args所指向的内存单元
int fseek(FILE *fp, long offset, int start);//将fp所指向的文件位置指针移到以start为基准,offset为偏移量的位置
long ftell(FILE *fp);//返回fp所指向的文件的读写位置
int fwrite(const void *buffer, int size, int count, FILE *source);//将buffer所指向的count*size个字节 输出到source所指向的文件中
int remove(char *fp);//删除出fp所指向的文件
int rename(char *oldName, char *newName);//重命名一个已存在的文件
void rewind(FILE *fp);//将fp所指向的文件位置指针置于文件开头位置,并清除文件结束标志和错误标志
字符操作函数:
int fputc(int ch, FILE *outfile);//向outfile所指向的文件中写入一个字符ch
int getc(FILE *infile);//从infile所指向的文件中读取下一个字符
int getchar(void);//从标准输入设备读取下一个字符
int printf(const char *format, argument_list);//argument_list的值以format指定的格式输出到标准输出设备
int putc(int ch, FILE *outfile);//向outfile所指向的文件中写入一个字符ch
int putchar(int ch);//把字符ch输出到标准输出设备上
int puts(const char *str);//把str指向的字符串输出到标准输出设备上,将’\0’转换为回车换行
int scanf(const char *format, args, …);//从标准输入设备按format指定的格式将输入数据送到args所指向的内存单元
2.标准系统库(stdlib.h)
数据操作函数:
int abs(int x);//返回x的绝对值
int rand(void);//返回范围在0-RAND_MAX(0x7fff)之间的一个随机数
void srand(unsigned seed);//初始化随机数发生器
类型转换函数:
double atof(const char *str);//将str所指向字符串转换为double型
int atoi(const char *str);//将str所指向字符串转换为int型
long atol(const char *str);//将str所指向字符串转换为long型
分配内存相关函数:
void *calloc(unsigned n, unsigned size);//分配n个大小size的连续内存空间
void free(void *fp);//释放fp所指的内存空间
void *malloc(unsigned size);//分配一个大小为size的内存空间
void *realloc(void *fp, unsigned size);//将fp所指的已分配内存空间的大小改为size,size可以比以前分配的大或小
void exit(int n);//系统退出函数,n为0时程序正常结束;n为1时,程序出现错误,立即终止
3.数学库(math.h)
三角函数相关函数:
double acos(double x);//计算cos^-1(x)的值
double asin(souble x);//计算sin^-1(x)的值
double atan(souble x);//计算tan^-1(x)的值
double atan2(souble x, double y);//计算tan^-1(x/y)的值
double cos(souble x);//计算cos(x)的值
double cosh(souble x);//计算x的双曲余弦函数值
double sin(double x);//计算sinx的值
double sinh(double x);//计算x的双曲正弦函数值
double tan(double x);//计算tanx的值
double tanh(double x);//计算x的双曲正切函数值
常数级计算函数:
int abs(int x);//返回x的绝对值
double fabs(double x);//计算x的绝对值
double floor(double x);//返回不大于x的最大整数
double fmod(double x, double y);//求整除x/y的余数
double frexp(double value, double *iptr);//把数value分成尾数部分x和以2为底的n次幂,即value=x*2^n,把n存到iptr指向的单元
long labs(long x);//计算x的绝对值
指数级计算函数:
double exp(double x);//指数函数,求e^x
double modf(double value, double *iptr);//把数value分为指数和尾数部分,把整数部分存到iptr指向的单元
double pow(double x, double y);//计算x^y的值
double sqrt(double x);//计算x^(1/2)
对数级计算函数:
double log(double x);//对数函数,求ln(x)的值
double log10(double x);//对数函数,求log10(x)的值
4.字符类型库(ctype.h)
int isalpha(int ch);//检查ch是否为字母
int isupper(int ch);//检查ch是否为大写字母(A-Z)
int islower(int ch);//检查ch是否为小写字母(a-z)
int isdigit(int ch);//检查ch是否为数字(0-9)
int isxdigit(int ch);//检查ch是否为一个十六进制数学字符(0-9、a-f、A-F)
int isspace(int ch);//检查ch是否为空格、制表符(tab)或换行符
int ispunct(int ch);//检查ch是否为可打印标点字符(不包括空格)
int alnum(int ch);//检查ch是否为字母或数字
int isprint(int ch);//检查ch是否为可打印字符(包括空格)
int isgraph(int ch);//检查ch是否为可打印字符(不包括空格)
int iscntrl(int ch);//检查ch是否为控制字符,其ASCII码在0-0x1f之间
int toupper(int ch);//将ch字符转换成大写字母
int tolower(int ch);//将ch字符转换成小写字母
5.字符串库(string.h)
char *strcpy(char *dst, const char *src);//将src所指向的字符串复制到dst所指向的内存单元
char *strcat(char *dst, const char *src);//将src所指向的字符串连接到dst所指向的字符串后面,dst最后面的’\0’被取消
char *strchr(char *str, int ch);//在str中找出ch第一次出现的位置
int strcmp(const char *str1, const char *str2);//比较两个字符串str1和str2
unsigned strlen(char *str);//统计str中字符的个数,不包括’\0’
char *strncat(char *dst, const char *src, int n);//从src中取n个字符复制到dst所指向的内存单元
char *strstr(char *str, char *substr);//在串str中查找指向字符串substr第一次出现位置