资源描述:
《c语言常用函数》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、函数名:abort功能:异常终止一个进程用法:voidabort(void);程序例:#include#includeintmain(void){printf("Callingabort()");abort();return0;/*Thisisneverreached*/}函数名:abs功能:求整数的绝对值用法:intabs(inti);程序例:#include#includeintmain(void){intnumber=-1234;printf("number:%dabsoluteval
2、ue:%d",number,abs(number));return0;}函数名:absread,abswirte功能:绝对磁盘扇区读、写数据用法:intabsread(intdrive,intnsects,intsectno,void*buffer);intabswrite(intdrive,intnsects,intsectno,void*buffer);程序例:/*absreadexample*/#include#include#include#includeintmain(void){
3、inti,strt,ch_out,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功能:
4、确定文件的访问权限用法:intaccess(constchar*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功能
5、:反余弦函数用法:doubleacos(doublex);程序例:#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#include6、io.h>intmain(void){unsignedintsize,segp;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,i
7、ntendangle,intradius);程序例:#include#include#include#includeintmain(void){/*requestautodetection*/intgdriver=DETECT,gmode,errorcode;intmidx,midy;intstangle=45,endangle=135;intradius=100;/*initializegraphicsandlocalvariables*/initgraph(&gdriver,&g