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