资源描述:
《c语言函数的功能和用法》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、函数名:abort功能:异常终止一个进程用法:voidabort(void);程序例:#include#includeintmain(void){printf("Callingabort()");abort();return0;/*Thisisneverreached*/}函数名:abs功能:求整数的绝对值用法:intabs(inti);程序例:#include#includeintmain(void){intnumber=-1234;printf("number:%dabsolutevalue:%d"
2、,number,abs(number));return0;}函数名:absread,abswirte功能:绝对磁盘扇区读、写数据用法:intabsread(intdrive,intnsects,intsectno,void*buffer);intabswrite(intdrive,intnsects,intsectno,void*buffer);程序例:/*absreadexample*/#include#include#include#includeintmain(void){inti,strt,ch_out
3、,sector;charbuf[512];printf("InsertadisketteintodriveAandpressanykey");getch();sector=0;if(absread(0,1,sector,&buf)!=0){perror("Diskproblem");exit(1);}printf("ReadOK");strt=3;for(i=0;i<80;i++){ch_out=buf[strt+i];putchar(ch_out);}printf("");return(0);}函数名:access功能:确定文件的访问权限用法:intaccess(co
4、nstchar*filename,intamode);程序例:#include#includeintfile_exists(char*filename);intmain(void){printf("DoesNOTEXIST.FILexist:%s",file_exists("NOTEXISTS.FIL")?"YES":"NO");return0;}intfile_exists(char*filename){return(access(filename,0)==0);}函数名:acos功能:反余弦函数用法:doubleacos(doublex);程序
5、例:#include#includeintmain(void){doubleresult;doublex=0.5;result=acos(x);printf("Thearccosineof%lfis%lf",x,result);return0;}函数名:allocmem功能:分配DOS存储段用法:intallocmem(unsignedsize,unsigned*seg);程序例:#include#include#includeintmain(void){unsignedintsize,segp
6、;intstat;size=64;/*(64x16)=1024bytes*/stat=allocmem(size,&segp);if(stat==-1)printf("Allocatedmemoryatsegment:%x",segp);elseprintf("Failed:maximumnumberofparagraphsavailableis%u",stat);return0;}函数名:arc功能:画一弧线用法:voidfararc(intx,inty,intstangle,intendangle,intradius);程序例:#include#
7、include#include#includeintmain(void){/*requestautodetection*/intgdriver=DETECT,gmode,errorcode;intmidx,midy;intstangle=45,endangle=135;intradius=100;/*initializegraphicsandlocalvariables*/initgraph(&gdriver,&