C语言库函数使用大全

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

C1-257CC2-257: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];C3-257printf(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.hC4-257intmain(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;C5-257intstangle=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*/C6-257t.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){C7-257assert(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;}C8-257: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);C9-257:#includestdlib.h#includestdio.hintmain(void){intn;char*str=12345.67;n=atoi(str);printf(string=%sinteger=%d\n,str,n);return0;}:atol::longatol(constchar*nptr);:#includestdlib.h#includestdio.hintmain(void){longl;char*str=98765432;l=atol(lstr);printf(string=%sinteger=%ld\n,str,l);return(0);}: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,);C10-257/*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*/for(i=SOLID_FILL;iUSER_FILL;i++){/*setthefillstyle*

1 / 257
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功