c语言库函数大全ab.docx
- 文档编号:4367257
- 上传时间:2022-12-01
- 格式:DOCX
- 页数:15
- 大小:19.33KB
c语言库函数大全ab.docx
《c语言库函数大全ab.docx》由会员分享,可在线阅读,更多相关《c语言库函数大全ab.docx(15页珍藏版)》请在冰豆网上搜索。
c语言库函数大全ab
c语言库函数大全a-b
2009-11-2710:
07
函数名:
abort
功能:
异常终止一个进程
用法:
voidabort(void);
程序例:
#include
#include
intmain(void)
{
printf("Callingabort()\n");
abort();
return0;/*实际上这句不会被执行*/
}
函数名:
abs
功能:
求整数的绝对值
用法:
intabs(inti);
程序例:
#include
#include
intmain(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*/
#include
#include
#include
#include
intmain(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;i<80;i++)
{
ch_out=buf[strt+i];
putchar(ch_out);
}
printf("\n");
return(0);
}
函数名:
access
功能:
确定文件的访问权限
用法:
intaccess(constchar*filename,intamode);
程序例:
#include
#include
intfile_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);
程序例:
#include
#include
intmain(void)
{
doubleresult;
doublex=0.5;
result=acos(x);
printf("Thearccosineof%lfis%lf\n",x,result);
return0;
}
函数名:
allocmem
功能:
分配DOS存储段
用法:
intallocmem(unsignedsize,unsigned*seg);
程序例:
#include
#include
#include
intmain(void)
{
unsignedintsize,segp;
intstat;
size=64;/*(64x16)=1024bytes*/
stat=allocmem(size,&segp);
if(stat==-1)
printf("Allocatedmemoryatsegment:
%x\n",segp);
else
printf("Failed:
maximumnumberofparagraphsavailableis%u\n",
stat);
return0;
}
函数名:
arc
功能:
画一弧线
用法:
voidfararc(intx,inty,intstangle,intendangle,intradius);
程序例:
#include
#include
#include
#include
intmain(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);
程序例:
#include
#include
#include
intmain(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*/
/*convertsstructuretonullterminated
string*/
strcpy(str,asctime(&t));
printf("%s\n",str);
return0;
}
函数名:
asin
功能:
反正弦函数
用法:
doubleasin(doublex);
程序例:
#include
#include
intmain(void)
{
doubleresult;
doublex=0.5;
result=asin(x);
printf("Thearcsinof%lfis%lf\n",x,result);
return(0);
}
函数名:
assert
功能:
测试一个条件并可能使程序终止
用法:
voidassert(inttest);
程序例:
#include
#include
#include
structITEM{
intkey;
intvalue;
};
/*additemtolist,makesurelistisnotnull*/
voidadditem(structITEM*itemptr){
assert(itemptr!
=NULL);
/*additemtolist*/
}
intmain(void)
{
additem(NULL);
return0;
}
函数名:
atan
功能:
反正切函数
用法:
doubleatan(doublex);
程序例:
#include
#include
intmain(void)
{
doubleresult;
doublex=0.5;
result=atan(x);
printf("Thearctangentof%lfis%lf\n",x,result);
return(0);
}
函数名:
atan2
功能:
计算Y/X的反正切值
用法:
doubleatan2(doubley,doublex);
程序例:
#include
#include
intmain(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);
程序例:
#include
#include
voidexit_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);
程序例:
#include
#include
intmain(void)
{
floatf;
char*str="12345.67";
f=atof(str);
printf("string=%sfloat=%f\n",str,f);
return0;
}
函数名:
atoi
功能:
把字符串转换成长整型数
用法:
intatoi(constchar*nptr);
程序例:
#include
#include
intmain(void)
{
intn;
char*str="12345.67";
n=atoi(str);
printf("string=%sinteger=%d\n",str,n);
return0;
}
函数名:
atol
功能:
把字符串转换成长整型数
用法:
longatol(constchar*nptr);
程序例:
#include
#include
intmain(void)
{
longl;
char*str="98765432";
l=atol(lstr);
printf("string=%sinteger=%ld\n",str,l);
return(0);
}
函数名:
bar
功能:
画一个二维条形图
用法:
voidfarbar(intleft,inttop,intright,intbottom);
程序例:
#include
#include
#include
#include
intmain(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*/
for(i=SOLID_FILL;i { /*setthefillstyle*/ setfillstyle(i,getmaxcolor()); /*drawthebar*/ bar(midx-50,midy-50,midx+50, midy+50); getch(); } /*cleanup*/ closegraph(); return0; } 函数名: bar3d 功能: 画一个三维条形图 用法: voidfarbar3d(intleft,inttop,intright,intbottom, intdepth,inttopflag); 程序例: #include #include #include #include intmain(void) { /*requestautodetection*/ intgdriver=DETECT,gmode,errorcode; intmidx,midy,i; /*initializegraphics,localvariables*/ initgraph(&gdriver,&gmode,""); /*readresultofinitialization*/ errorcode=graphresult(); if(errorcode! =grOk)/*anerroroccurred*/ { printf("Graphicserror: %s\n",grapherrormsg(errorcode)); printf("Pressanykeytohalt: "); getch(); exit (1);/*terminatewitherrorcode*/ } midx=getmaxx()/2; midy=getmaxy()/2; /*loopthroughthefillpatterns*/ for(i=EMPTY_FILL;i { /*setthefillstyle*/ setfillstyle(i,getmaxcolor()); /*drawthe3-dbar*/ bar3d(midx-50,midy-50,midx+50,midy+50,10,1); getch(); } /*cleanup*/ closegraph(); return0; } 函数名: bdos 功能: DOS系统调用 用法: intbdos(intdosfun,unsigneddosdx,unsigneddosal); 程序例: #include #include /*Getcurrentdriveas'A','B',...*/ charcurrent_drive(void) { charcurdrive; /*Getcurrentdiskas0,1,...*/ curdrive=bdos(0x19,0,0); return('A'+curdrive); } intmain(void) { printf("Thecurrentdriveis%c: \n",current_drive()); return0; } 函数名: bdosptr 功能: DOS系统调用 用法: intbdosptr(intdosfun,void*argument,unsigneddosal); 程序例: #include #include #include #include #include #include #defineBUFLEN80 intmain(void) { charbuffer[BUFLEN]; inttest; printf("Enterfullpathnameofadirectory\n"); gets(buffer); test=bdosptr(0x3B,buffer,0); if(test) { printf("DOSerrormessage: %d\n",errno); /*Seeerrno.hforerrorlistings*/ exit (1); } getcwd(buffer,BUFLEN); printf("Thecurrentdirectoryis: %s\n",buffer); return0; } 函数名: bioscom 功能: 串行I/O通信 用法: intbioscom(intcmd,charabyte,intport); 程序例: #include #include #defineCOM10 #defineDATA_READY0x100 #defineTRUE1 #defineFALSE0 #defineSETTINGS(0x80|0x02|0x00|0x00) intmain(void) { intin,out,status,DONE=FALSE; bioscom(0,SETTINGS,COM1); cprintf("...BIOSCOM[ESC]toexit...\n"); while(! DONE) { status=bioscom(3,0,COM1); if(status&DATA_READY) if((out=bioscom(2,0,COM1)&0x7F)! =0) putch(out); if(kbhit()) { if((in=getch())=='\x1B') DONE=TRUE; bioscom(1,in,COM1); } } return0; } 函数名: biosdisk 功能: 软硬盘I/O 用法: intbiosdisk(intcmd,intdrive,inthead,inttrack,intsector intnsects,void*buffer); 程序例: #include #in
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 库函数 大全 ab
![提示](https://static.bdocx.com/images/bang_tan.gif)