***************数学相关**************** 1、函数名称: abs函数原型: int abs(int x);函数功能: 求整数x的绝对值函数返回: 计算结果参数说明:所属文件: <>,<>使用范例:#include <>#include <>int main(){int number=-1234;printf("number: %d absolute value: %d",number,abs(number)); return 0;}2、函数名称: fabs函数原型: double fabs(double x);函数功能: 求x的绝对值.函数返回: 计算结果参数说明:所属文件: <>使用范例:#include <>#include <>int main(){float number=;printf("number: %f absolute value: %f",number,fabs(number)); return 0;}3、函数名称: sqrt函数原型: double sqrt(double x);函数功能: 计算x的开平方.函数返回: 计算结果参数说明: x>=0所属文件: <>使用范例:#include <>#include <>int main(){double x=,result;result=sqrt(x);printf("The square root of %lf is %lf",x,result);return 0;}4、函数名称: pow函数原型: double pow(double x,double y);函数功能: 计算以x为底数的y次幂,即计算x^y的值.函数返回: 计算结果参数说明: x-底数,y-幂数所属文件: <>使用范例:#include <>#include <>int main(){double x=,y=;printf("%lf raised to %lf is %lf",x,y,pow(x,y)); return 0;}5、函数名称: sin函数原型: double sin(double x);函数功能: 计算sinx的值.正弦函数函数返回: 计算结果参数说明: 单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result,x=;result=sin(x);printf("The sin() of %lf is %lf",x,result); return 0;}6、函数名称: cos函数原型: double cos(double x);函数功能: 计算cos(x)的值.余弦函数.函数返回: 计算结果参数说明: x的单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=cos(x);printf("The cosine of %lf is %lf",x,result); return 0;}7、函数名称: tan函数原型: double tan(double x);函数功能: 计算tan(x)的值,即计算角度x的正切数值函数返回: 计算结果参数说明: x>=0单位为弧度所属文件: <>使用范例:#include <>#include <>int main(){double result,x;x=;result=tan(x);printf("The tan of %lf is %lf",x,result);return 0;}8、函数名称: rand9、函数原型: int rand(void);10、函数功能: 产生0到32767间的随机整数(0到0x7fff之间)11、函数返回: 随机整数12、参数说明:13、所属文件: <>14、15、#include <>16、#include <>17、int main()18、{19、int i;20、printf("Ten random numbers from 0 to 99");21、for(i=0;i<10;i++)22、printf("%d",rand()%100);23、return 0;24、}函数名称: log函数原型: double log(double x);函数功能: 求logeX(e指的是以e为底),即计算x的自然对数(ln X) 函数返回: 计算结果参数说明:所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=log(x);printf("The natural log of %lf is %lf",x,result);return 0;}函数名称: log10函数原型: double log10(double x);函数功能: 求log10x(10指的是以10为底).计算x的常用对数函数返回: 计算结果参数说明:所属文件: <>使用范例:#include <>#include <>int main(){double result;double x=;result=log10(x);printf("The common log of %lf is %lf",x,result); return 0;}***************字符串相关****************1、函数名称: strcpy2、函数原型: char* strcpy(char* str1,char* str2);3、函数功能: 把str2指向的字符串拷贝到str1中去4、函数返回: 返回str1,即指向str1的指针5、参数说明:6、所属文件: <>7、8、#include <>9、#include <>10、int main()11、{12、char string[10];13、char *str1="abcdefghi";14、strcpy(string,str1);15、printf("the string is:%s\n",string);16、return 0;17、}18、函数名称: strcat19、函数原型: char* strcat(char * str1,char * str2);20、函数功能: 把字符串str2接到str1后面,str1最后的'\0'被取消21、函数返回: str122、参数说明:23、所属文件: <>24、25、#include <>26、#include <>27、28、int main()29、{30、char buffer[80];31、32、strcpy(buffer,"Hello ");33、strcat(buffer,"world");34、printf("%s\n",buffer);35、return 0;36、}37、函数名称: strcmp38、函数原型: int strcmp(char * str1,char * str2);39、函数功能: 比较两个字符串str1,str2.40、函数返回: str1<str2,返回负数; str1=str2,返回 0; str1>str2,返回正数.41、参数说明:42、所属文件: <>43、44、#include <>45、#include <>46、int main()47、{48、char *buf1="aaa", *buf2="bbb", *buf3="ccc";49、int ptr;50、ptr=strcmp(buf2, buf1);51、if(ptr>0)52、printf("buffer 2 is greater than buffer 1\n");53、else54、printf("buffer 2 is less than buffer 1\n");55、ptr=strcmp(buf2, buf3);56、if(ptr>0)57、printf("buffer 2 is greater than buffer 3\n");58、else59、printf("buffer 2 is less than buffer 3\n");60、return 0;61、}62、函数名称: strlen63、函数原型: unsigned int strlen(char * str);64、函数功能: 统计字符串str中字符的个数(不包括终止符'\0')65、函数返回: 返回字符串的长度.66、参数说明:67、所属文件: <>68、69、#include <>70、#include<>71、int main()72、{73、char str[]="how are you!";74、printf("the lence is:%d\n",strlen(str));75、return 0;**********************文件相关*****************1、函数名称: fopen2、函数原型: FILE *fopen(char * filename,char * mode);3、函数功能: 以mode指定的方式打开名为filename的文件4、函数返回: 成功,返回一个文件指针(文件信息区的起始地址),否则返回05、参数说明: filename-文件名称,mode-打开模式:6、r 只读方式打开一个文本文件7、rb 只读方式打开一个二进制文件8、w 只写方式打开一个文本文件9、wb 只写方式打开一个二进制文件10、a 追加方式打开一个文本文件11、ab 追加方式打开一个二进制文件12、r+ 可读可写方式打开一个文本文件13、rb+ 可读可写方式打开一个二进制文件14、w+ 可读可写方式创建一个文本文件15、wb+ 可读可写方式生成一个二进制文件16、a+ 可读可写追加方式打开一个文本文件17、ab+ 可读可写方式追加一个二进制文件18、函数名称: fclose19、函数原型: int fclose(FILE * fp);20、函数功能: 关闭fp所指的文件,释放文件缓冲区21、函数返回: 0-无错,否则非零22、参数说明:23、所属文件: <>24、函数名称: fgetc25、函数原型: int fgetc(FILE * fp);26、函数功能: 从fp所指定的文件中取得下一个字符27、函数返回: 返回所得到的字符.若读入出错,返回EOF28、参数说明: fp-文件指针29、所属文件: <>30、函数名称: fgets31、函数原型: char fgets(char * buf,int n,FILE * fp);32、函数功能: 从fp指向的文件中读取一个长度为(n-1)的字符串,存入起始地址为buf的空间33、函数返回: 返回地址buf,若遇文件结束或出错,返回NULL34、函数说明: buf-存放读入的字符数组指针,n-最大允许的读入字符数,fp-文件指针35、所属文件: <>36、函数名称: feof37、函数原型: int feof(FILE * fp);38、函数功能: 检查文件是否结束.39、函数返回: 遇文件结束符返回非零值,否则返回040、参数说明: fp-文件指针41、所属文件: <>42、函数名称: fputc43、函数原型: int fputc(char ch,FILE *fp);44、函数功能: 将字符ch输出到fp指向的文件中45、函数返回: 成功,则返回该字符;否则返回非046、参数说明: fp-文件指针,ch-要写入的字符(舍去高位字节)47、所属文件: <>48、函数名称: fputs49、函数原型: int fputs(char * str,FILE *fp);50、函数功能: 将str指向的字符串输出到fp指向的文件中51、函数返回: 成功,则返回0;否则返回非052、参数说明:53、所属文件: <>54、函数名称: fprintf55、函数原型: int fprintf(FILE * fp,char * format,args,...);56、函数功能: 把args的值以format指定的格式输出到fp所指定的流式文件中57、函数返回: 实际输出的字符数58、参数说明: fp-目标文件,format-格式符59、所属文件: <>60、函数名称: fscanf61、函数原型: int fscanf(FILE * fp,char format,args,...);62、函数功能: 从fp所指定的文件中按format给定的格式将数据输送到args所指向的内存单元63、函数返回: 已输入的数据个数64、参数说明:65、所属文件: <>66、函数名称: fseek67、函数原型: int fseek(FILE * fp,long offset,int base);68、函数功能: 将fp所指文件的位置指针移到以base所指位置为基准,以offset为位移量的位置69、函数返回: 返回当前位置,否则返回-170、参数说明: fp-文件指针71、offset-相对于origin规定的偏移位置量72、origin-指针移动的起始位置,可设置为以下三种情况:73、SEEK_SET 文件开始位置 074、SEEK_CUR 文件当前位置 175、SEEK_END 文件结束位置 276、所属文件: <>77、78、#include <>79、long filesize(FILE *stream);80、int main()81、{82、FILE *stream;83、stream=fopen("","w+");84、fprintf(stream,"This is a test");85、printf("Filesize of is %ld bytes",filesize(stream));86、fclose(stream);87、return 0;88、}89、long filesize(FILE *stream)90、{91、long curpos,length;92、curpos=ftell(stream);93、fseek(stream,0L,SEEK_END);94、length=ftell(stream);95、fseek(stream,curpos,SEEK_SET);96、return length;97、}98、函数名称: ftell99、函数原型: long ftell(FILE * fp);100、函数功能: 得到文件位置指示器的数值101、函数返回: fp指向的文件中的读写位置102、参数说明:103、所属文件: <>104、105、#include <>106、int main()107、{108、FILE *stream;109、stream=fopen("","w+");110、fprintf(stream,"This is a test");111、printf("The file pointer is at byte %ld",ftell(stream)); 112、fclose(stream);113、return 0;114、}****************开辟空间***************1、函数名称: malloc2、函数原型: void * malloc(unsigned size);3、函数功能: 分配size字节的存储区4、函数返回: 所分配的内存区地址,如果内存不够,返回05、参数说明:6、所属文件: <>7、8、#include <>9、#include <>10、#include <>11、int main()12、{13、char *str;14、if((str=malloc(10))==NULL)15、{16、printf("Not enough memory to allocate buffer");17、exit(1);18、}19、strcpy(str,"Hello");20、printf("String is %s",str);21、free(str);22、return 0;23、}24、函数名称: realloc25、函数原型: void * realloc(void * p,unsigned size);26、函数功能: 将p所指出的已分配内存区的大小改为size,size可以比原来分配的空间大或小27、函数返回: 返回指向该内存区的指针.NULL-分配失败28、参数说明:29、所属文件: <>30、31、#include <>32、#include <>33、#include <>34、int main()35、{36、char *str;37、str= malloc(10);38、strcpy(str,"Hello");39、printf("String is %s Address is %p",str,str);40、str=realloc(str,20);41、printf("String is %s New address is %p",str,str);42、free(str);43、return 0;44、}***************输入输出****************函数名称: scanf函数原型: int scanf(char * format,args,...);函数功能: 从标准输入设备按format指向的格式字符串规定的格式,输入数据给agrs所指向的单元函数返回: 读入并赋给args的数据个数.遇文件结束返回EOF,出错返回0参数说明: args-指针所属文件: <>int main(){int a,b,c;scanf("%d%d%d",&a,&b,&c);printf("%d,%d,%d\n",a,b,c);return 0;}函数名称: printf函数原型: int printf(char * format,args,...);函数功能: 按format指向的格式字符串所规定的格式,将输出表列args的值输出到标准输出设备函数返回: 输出字符的个数.若出错返回负数参数说明: format-是一个字串,或字符数组的起始地址所属文件: <>#include <>int main(){char c='a';int i=97;printf("%c,%d\n",c,c);printf("%c,%d\n",i,i);return 0;}函数名称: getc函数原型: int getc(FILE *fp);函数功能: 从fp所指向的文件中读入一个字符函数返回: 返回所读的字符,若文件结束或出错,返回EOF 参数说明:所属文件: <>#include <>int main(){char ch;printf("Input a character:");ch=getc(stdin);printf("The character input was: '%c'",ch);return 0;}函数名称: putc函数原型: int putc(int ch,FILE * fp);函数功能: 把一个字符ch输出到fp所指定的文件中函数返回: 输出字符ch,若出错,返回EOF参数说明:所属文件: <>#include <>int main(){char msg[]="Hello world";int i=0;while (msg[i])putc(msg[i++],stdout);return 0;}函数名称: puts函数原型: int puts(char * str);函数功能: 把str指向的字符串输出到标准输出设备,将'\0'转换为回车换行函数返回: 返回换行符,若失败,返回EOF参数说明:所属文件: <>#include <>int main(){char string[]="This is an example output string";puts(string);return 0;}函数名称: gets函数原型: char * gets(char *str)函数功能: 从终端输入一个字符串到字符数组,并且得到一个函数值.该函数值是字符数组的起始地址函数返回: 读取的字符指针str,操作错误返回NULL参数说明: str-保存读取的字符串所属文件: <>#include <>int main(){char buffer[80];while(gets(buffer)!=NULL)puts(buffer);return 0;}。