C语言函数b开头.docx
- 文档编号:28972374
- 上传时间:2023-07-20
- 格式:DOCX
- 页数:12
- 大小:16.78KB
C语言函数b开头.docx
《C语言函数b开头.docx》由会员分享,可在线阅读,更多相关《C语言函数b开头.docx(12页珍藏版)》请在冰豆网上搜索。
C语言函数b开头
函数大全(b开头)
61
函数名:
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
#include
intmain(void)
{
intresult;
charbuffer[512];
printf("Testingtoseeifdrivea:
isready\n");
result=biosdisk(4,0,0,0,0,1,buffer);
result&=0x02;
(result)?
(printf("DriveA:
Ready\n")):
(printf("DriveA:
NotReady\n"));
return0;
}
函数名:
biosequip
功能:
检查设备
用法:
intbiosequip(void);
程序例:
#include
#include
intmain(void)
{
intresult;
charbuffer[512];
printf("Testingtoseeifdrivea:
isready\n");
result=biosdisk(4,0,0,0,0,1,buffer);
result&=0x02;
(result)?
(printf("DriveA:
Ready\n")):
(printf("DriveA:
NotReady\n"));
return0;
}
函数名:
bioskey
功能:
直接使用BIOS服务的键盘接口
用法:
intbioskey(intcmd);
程序例:
#include
#include
#include
#defineRIGHT0x01
#defineLEFT0x02
#defineCTRL0x04
#defineALT0x08
intmain(void)
{
intkey,modifiers;
/*function1returns0untilakeyispressed*/
while(bioskey
(1)==0);
/*function0returnsthekeythatiswaiting*/
key=bioskey(0);
/*usefunction2todetermineifshiftkeyswereused*/
modifiers=bioskey
(2);
if(modifiers)
{
printf("[");
if(modifiers&RIGHT)printf("RIGHT");
if(modifiers&LEFT)printf("LEFT");
if(modifiers&CTRL)printf("CTRL");
if(modifiers&ALT)printf("ALT");
printf("]");
}
/*printoutthecharacterread*/
if(isalnum(key&0xFF))
printf("'%c'\n",key);
else
printf("%#02x\n",key);
return0;
}
函数名:
biosmemory
功能:
返回存储块大小
用法:
intbiosmemory(void);
程序例:
#include
#include
intmain(void)
{
intmemory_size;
memory_size=biosmemory();/*returnsvalueupto640K*/
printf("RAMsize=%dK\n",memory_size);
return0;
}
函数名:
biosprint
功能:
直接使用BIOS服务的打印机I/O
用法:
intbiosprint(intcmd,intbyte,intport);
程序例:
#include
#include
#include
intmain(void)
{
#defineSTATUS2/*printerstatuscommand*/
#definePORTNUM0/*portnumberforLPT1*/
intstatus,abyte=0;
printf("Pleaseturnoffyourprinter.Pressanykeytocontinue\n");
getch();
status=biosprint(STATUS,abyte,PORTNUM);
if(status&0x01)
printf("Devicetimeout.\n");
if(status&0x08)
printf("I/Oerror.\n");
if(status&0x10)
printf("Selected.\n");
if(status&0x20)
printf("Outofpaper.\n");
if(status&0x40)
printf("Acknowledge.\n");
if(status&0x80)
printf("Notbusy.\n");
return0;
}
函数名:
biostime
功能:
读取或设置BIOS时间
用法:
longbiostime(intcmd,longnewtime);
程序例:
#include
#include
#include
#include
intmain(void)
{
longbios_time;
clrscr();
cprintf("Thenumberofclocktickssincemidnightis:
\r\n");
cprintf("Thenumberofsecondssincemidnightis:
\r\n");
cprintf("Thenumberofminutessincemidnightis:
\r\n");
cprintf("Thenumberofhourssincemidnightis:
\r\n");
cprintf("\r\nPressanykeytoquit:
");
while(!
kbhit())
{
bios_time=biostime(0,0L);
gotoxy(50,1);
cprintf("%lu",bios_time);
gotoxy(50,2);
cprintf("%.4f",bios_time/CLK_TCK);
gotoxy(50,3);
cprintf("%.4f",bios_time/CLK_TCK/60);
gotoxy(50,4);
cprintf("%.4f",bios_time/CLK_TCK/3600);
}
return0;
}
函数名:
brk
功能:
改变数据段空间分配
用法:
intbrk(void*endds);
程序例:
#include
#include
intmain(void)
{
char*ptr;
printf("Changingallocationwithbrk()\n");
ptr=malloc
(1);
printf("Beforebrk()call:
%lubytesfree\n",coreleft());
brk(ptr+1000);
printf("Afterbrk()call:
%lubytesfree\n",coreleft());
return0;
}
函数名:
bsearch
功能:
二分法搜索
用法:
void*bsearch(constvoid*key,constvoid*base,size_t*nelem,
size_twidth,int(*fcmp)(constvoid*,const*));
程序例:
#include
#include
#defineNELEMS(arr)(sizeof(arr)/sizeof(arr[0]))
intnumarray[]={123,145,512,627,800,933};
intnumeric(constint*p1,constint*p2)
{
return(*p1-*p2);
}
intlookup(intkey)
{
int*itemptr;
/*Thecastof(int(*)(constvoid*,constvoid*))
isneededtoavoidatypemismatcherrorat
compiletime*/
itemptr=bsearch(&key,numarray,NELEMS(numarray),
sizeof(int),(int(*)(constvoid*,constvoid*))numeric);
return(itemptr!
=NULL);
}
intmain(void)
{
if(lookup(512))
printf("512isinthetable.\n");
else
printf("512isn'tinthetable.\n");
return0;
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 函数 开头