您好,欢迎访问三七文档
A函数名:abort功能:异常终止一个进程用法:voidabort(void);程序例:#includestdio.h#includestdlib.hintmain(void){printf(Callingabort()\n);abort();return0;/*Thisisneverreached*/}函数名:abs功能:求整数的绝对值用法:intabs(inti);程序例:#includestdio.h#includemath.hintmain(void){intnumber=-1234;printf(number:%dabsolutevalue:%d\n,number,abs(number));return0;}函数名:absread,abswirte功能:绝对磁盘扇区读、写数据用法:intabsread(intdrive,intnsects,intsectno,void*buffer);intabswrite(intdrive,intnsects,intsectno,void*buffer);程序例:/*absreadexample*/#includestdio.h#includeconio.h#includeprocess.h#includedos.hintmain(void){inti,strt,ch_out,sector;charbuf[512];printf(InsertadisketteintodriveAandpressanykey\n);getch();sector=0;if(absread(0,1,sector,&buf)!=0){perror(Diskproblem);exit(1);}printf(ReadOK\n);strt=3;for(i=0;i80;i++){ch_out=buf[strt+i];putchar(ch_out);}printf(\n);return(0);}函数名:access功能:确定文件的访问权限用法:intaccess(constchar*filename,intamode);程序例:#includestdio.h#includeio.hintfile_exists(char*filename);intmain(void){printf(DoesNOTEXIST.FILexist:%s\n,file_exists(NOTEXISTS.FIL)?YES:NO);return0;}intfile_exists(char*filename){return(access(filename,0)==0);}函数名:acos功能:反余弦函数用法:doubleacos(doublex);程序例:#includestdio.h#includemath.hintmain(void){doubleresult;doublex=0.5;result=acos(x);printf(Thearccosineof%lfis%lf\n,x,result);return0;}函数名:allocmem功能:分配DOS存储段用法:intallocmem(unsignedsize,unsigned*seg);程序例:#includedos.h#includealloc.h#includestdio.hintmain(void){unsignedintsize,segp;intstat;size=64;/*(64x16)=1024bytes*/stat=allocmem(size,&segp);if(stat==-1)printf(Allocatedmemoryatsegment:%x\n,segp);elseprintf(Failed:maximumnumberofparagraphsavailableis%u\n,stat);return0;}函数名:arc功能:画一弧线用法:voidfararc(intx,inty,intstangle,intendangle,intradius);程序例:#includegraphics.h#includestdlib.h#includestdio.h#includeconio.hintmain(void){/*requestautodetection*/intgdriver=DETECT,gmode,errorcode;intmidx,midy;intstangle=45,endangle=135;intradius=100;/*initializegraphicsandlocalvariables*/initgraph(&gdriver,&gmode,);/*readresultofinitialization*/errorcode=graphresult();/*anerroroccurred*/if(errorcode!=grOk){printf(Graphicserror:%s\n,grapherrormsg(errorcode));printf(Pressanykeytohalt:);getch();exit(1);/*terminatewithanerrorcode*/}midx=getmaxx()/2;midy=getmaxy()/2;setcolor(getmaxcolor());/*drawarc*/arc(midx,midy,stangle,endangle,radius);/*cleanup*/getch();closegraph();return0;}函数名:asctime功能:转换日期和时间为ASCII码用法:char*asctime(conststructtm*tblock);程序例:#includestdio.h#includestring.h#includetime.hintmain(void){structtmt;charstr[80];/*sampleloadingoftmstructure*/t.tm_sec=1;/*Seconds*/t.tm_min=30;/*Minutes*/t.tm_hour=9;/*Hour*/t.tm_mday=22;/*DayoftheMonth*/t.tm_mon=11;/*Month*/t.tm_year=56;/*Year-doesnotincludecentury*/t.tm_wday=4;/*Dayoftheweek*/t.tm_yday=0;/*Doesnotshowinasctime*/t.tm_isdst=0;/*IsDaylightSavTime;doesnotshowinasctime*//*convertsstructuretonullterminatedstring*/strcpy(str,asctime(&t));printf(%s\n,str);return0;}函数名:asin功能:反正弦函数用法:doubleasin(doublex);程序例:#includestdio.h#includemath.hintmain(void){doubleresult;doublex=0.5;result=asin(x);printf(Thearcsinof%lfis%lf\n,x,result);return(0);}函数名:assert功能:测试一个条件并可能使程序终止用法:voidassert(inttest);程序例:#includeassert.h#includestdio.h#includestdlib.hstructITEM{intkey;intvalue;};/*additemtolist,makesurelistisnotnull*/voidadditem(structITEM*itemptr){assert(itemptr!=NULL);/*additemtolist*/}intmain(void){additem(NULL);return0;}函数名:atan功能:反正切函数用法:doubleatan(doublex);程序例:#includestdio.h#includemath.hintmain(void){doubleresult;doublex=0.5;result=atan(x);printf(Thearctangentof%lfis%lf\n,x,result);return(0);}函数名:atan2功能:计算Y/X的反正切值用法:doubleatan2(doubley,doublex);程序例:#includestdio.h#includemath.hintmain(void){doubleresult;doublex=90.0,y=45.0;result=atan2(y,x);printf(Thearctangentratioof%lfis%lf\n,(y/x),result);return0;}函数名:atexit功能:注册终止函数用法:intatexit(atexit_tfunc);程序例:#includestdio.h#includestdlib.hvoidexit_fn1(void){printf(Exitfunction#1called\n);}voidexit_fn2(void){printf(Exitfunction#2called\n);}intmain(void){/*postexitfunction#1*/atexit(exit_fn1);/*postexitfunction#2*/atexit(exit_fn2);return0;}函数名:atof功能:把字符串转换成浮点数用法:doubleatof(constchar*nptr);程序例:#includestdlib.h#includestdio.hintmain(void){floatf;char*str=12345.67;f=atof(str);printf(string=%sfloat=%f\n,str,f);return0;}函数名:atoi功能:把字符串转换成长整型数用法:intatoi(constchar*nptr);程序例:#includestdlib.h#includestdio.hintmain(void){intn;char*str=1234;n=atof(str);printf(string=%sfloat=%d\n,str,n);return0;}函数名:bar功能:画一个二维条形图用法:voidfarbar(intleft,inttop,intright,intbottom);程序例:#includegraphics.h#includestdlib.h#includestdio.h#includeconio.hintmain(void){/*requestautodetection*/intgdriver=DETECT,gmode,errorcode;intmidx,midy,i;/*initializegraphicsandlocalvariables*/initgraph(&gdriver,&gmode,);/*readresultofinitialization*/errorcode=graphresult();if(errorcode!=grOk)/*anerroroccurred*/{printf(Graphicserror:%s\n,grapherrormsg(errorcode));printf(Pressanykeytohalt:);getch();exit(1);/*terminatewithanerrorcode*/}midx=getmaxx()/2;midy=getmaxy()/2;/*loopthroughthefillpatterns*/fo
本文标题:C语言标准函数库
链接地址:https://www.777doc.com/doc-4813850 .html