⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 b.htm

📁 C语言函数库,包含所有的C语言函数
💻 HTM
字号:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body bgcolor="#00FFFF" text="#000080">

<PRE><font size="5"><a href="a.htm">A</a> <a href="b.htm">B</a> <a href="c.htm">C</a> <a href="d.htm">D</a> <a href="e.htm">E</a> <a href="f.htm">F</a> <a href="g.htm">G</a> <a href="h.htm">H</a> <a href="i.htm">I</a> <a href="k.htm">K</a> <a href="l.htm">L</a> <a href="m.htm">M</a> <a href="n.htm">N</a> <a href="o.htm">O</a> <a href="p.htm">P</a> <a href="q.htm">Q</a> <a href="r.htm">R</a> <a href="s.htm">S</a> <a href="t.htm">T</a> <a href="u.htm">U</a> <a href="v.htm">V</a> <a href="w.htm">W</a> </font></PRE>

<PRE>函数大全(b开头)</PRE>
<PRE>函数名: <font size="5" color="#FF0000">bar</font> 
功 能: 画一个二维条形图 
用 法: void far bar(int left, int top, int right, int bottom); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
/* request auto detection */ 
int gdriver = DETECT, gmode, errorcode; 
int midx, midy, i; </PRE>
<PRE>/* initialize graphics and local variables */ 
initgraph(&amp;gdriver, &amp;gmode, &quot;&quot;); </PRE>
<PRE>/* read result of initialization */ 
errorcode = graphresult(); 
if (errorcode != grOk) /* an error occurred */ 
{ 
printf(&quot;Graphics error: %s\n&quot;, grapherrormsg(errorcode)); 
printf(&quot;Press any key to halt:&quot;); 
getch(); 
exit(1); /* terminate with an error code */ 
} </PRE>
<PRE>midx = getmaxx() / 2; 
midy = getmaxy() / 2; </PRE>
<PRE>/* loop through the fill patterns */ 
for (i=SOLID_FILL; i { 
/* set the fill style */ 
setfillstyle(i, getmaxcolor()); </PRE>
<PRE>/* draw the bar */ 
bar(midx-50, midy-50, midx+50, 
midy+50); </PRE>
<PRE>getch(); 
} </PRE>
<PRE>/* clean up */ 
closegraph(); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> bar3d </font>
功 能: 画一个三维条形图 
用 法: void far bar3d(int left, int top, int right, int bottom, 
int depth, int topflag); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
/* request auto detection */ 
int gdriver = DETECT, gmode, errorcode; 
int midx, midy, i; </PRE>
<PRE>/* initialize graphics, local variables */ 
initgraph(&amp;gdriver, &amp;gmode, &quot;&quot;); </PRE>
<PRE>/* read result of initialization */ 
errorcode = graphresult(); 
if (errorcode != grOk) /* an error occurred */ 
{ 
printf(&quot;Graphics error: %s\n&quot;, grapherrormsg(errorcode)); 
printf(&quot;Press any key to halt:&quot;); 
getch(); 
exit(1); /* terminate with error code */ 
} </PRE>
<PRE>midx = getmaxx() / 2; 
midy = getmaxy() / 2; </PRE>
<PRE>/* loop through the fill patterns */ 
for (i=EMPTY_FILL; i { 
/* set the fill style */ 
setfillstyle(i, getmaxcolor()); </PRE>
<PRE>/* draw the 3-d bar */ 
bar3d(midx-50, midy-50, midx+50, midy+50, 10, 1); </PRE>
<PRE>getch(); 
} </PRE>
<PRE>/* clean up */ 
closegraph(); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> bdos</font> 
功 能: DOS系统调用 
用 法: int bdos(int dosfun, unsigned dosdx, unsigned dosal); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>/* Get current drive as 'A', 'B', ... */ 
char current_drive(void) 
{ 
char curdrive; </PRE>
<PRE>/* Get current disk as 0, 1, ... */ 
curdrive = bdos(0x19, 0, 0); 
return('A' + curdrive); 
} </PRE>
<PRE>int main(void) 
{ 
printf(&quot;The current drive is %c:\n&quot;, current_drive()); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> bdosptr </font>
功 能: DOS系统调用 
用 法: int bdosptr(int dosfun, void *argument, unsigned dosal); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include 
#include 
#include </PRE>
<PRE>#define BUFLEN 80 </PRE>
<PRE>int main(void) 
{ 
char buffer[BUFLEN]; 
int test; </PRE>
<PRE>printf(&quot;Enter full pathname of a directory\n&quot;); 
gets(buffer); </PRE>
<PRE>test = bdosptr(0x3B,buffer,0); 
if(test) 
{ 
printf(&quot;DOS error message: %d\n&quot;, errno); 
/* See errno.h for error listings */ 
exit (1); 
} </PRE>
<PRE>getcwd(buffer, BUFLEN); 
printf(&quot;The current directory is: %s\n&quot;, buffer); </PRE>
<PRE>return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> bioscom </font>
功 能: 串行I/O通信 
用 法: int bioscom(int cmd, char abyte, int port); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>#define COM1 0 
#define DATA_READY 0x100 
#define TRUE 1 
#define FALSE 0 </PRE>
<PRE>#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00) </PRE>
<PRE>int main(void) 
{ 
int in, out, status, DONE = FALSE; </PRE>
<PRE>bioscom(0, SETTINGS, COM1); 
cprintf(&quot;... BIOSCOM [ESC] to exit ...\n&quot;); 
while (!DONE) 
{ 
status = bioscom(3, 0, COM1); 
if (status &amp; DATA_READY) 
if ((out = bioscom(2, 0, COM1) &amp; 0x7F) != 0) 
putch(out); 
if (kbhit()) 
{ 
if ((in = getch()) == '\x1B') 
DONE = TRUE; 
bioscom(1, in, COM1); 
} 
} 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">biosdisk </font>
功 能: 软硬盘I/O 
用 法: int biosdisk(int cmd, int drive, int head, int track, int sector 
int nsects, void *buffer); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
int result; 
char buffer[512]; </PRE>
<PRE>printf(&quot;Testing to see if drive a: is ready\n&quot;); 
result = biosdisk(4,0,0,0,0,1,buffer); 
result &amp;= 0x02; 
(result) ? (printf(&quot;Drive A: Ready\n&quot;)) : 
(printf(&quot;Drive A: Not Ready\n&quot;)); </PRE>
<PRE>return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> biosequip </font>
功 能: 检查设备 
用 法: int biosequip(void); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
int result; 
char buffer[512]; </PRE>
<PRE>printf(&quot;Testing to see if drive a: is ready\n&quot;); 
result = biosdisk(4,0,0,0,0,1,buffer); 
result &amp;= 0x02; 
(result) ? (printf(&quot;Drive A: Ready\n&quot;)) : 
(printf(&quot;Drive A: Not Ready\n&quot;)); </PRE>
<PRE>return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">bioskey </font>
功 能: 直接使用BIOS服务的键盘接口 
用 法: int bioskey(int cmd); 
程序例: </PRE>
<PRE>#include 
#include 
#include </PRE>
<PRE>#define RIGHT 0x01 
#define LEFT 0x02 
#define CTRL 0x04 
#define ALT 0x08 </PRE>
<PRE>int main(void) 
{ 
int key, modifiers; </PRE>
<PRE>/* function 1 returns 0 until a key is pressed */ 
while (bioskey(1) == 0); </PRE>
<PRE>/* function 0 returns the key that is waiting */ 
key = bioskey(0); </PRE>
<PRE>/* use function 2 to determine if shift keys were used */ 
modifiers = bioskey(2); 
if (modifiers) 
{ 
printf(&quot;[&quot;); 
if (modifiers &amp; RIGHT) printf(&quot;RIGHT&quot;); 
if (modifiers &amp; LEFT) printf(&quot;LEFT&quot;); 
if (modifiers &amp; CTRL) printf(&quot;CTRL&quot;); 
if (modifiers &amp; ALT) printf(&quot;ALT&quot;); 
printf(&quot;]&quot;); 
} 
/* print out the character read */ 
if (isalnum(key &amp; 0xFF)) 
printf(&quot;'%c'\n&quot;, key); 
else 
printf(&quot;%#02x\n&quot;, key); 
return 0; 
} 

</PRE>
<PRE>函数名: <font size="5" color="#FF0000">biosmemory </font>
功 能: 返回存储块大小 
用 法:int biosmemory(void); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
int memory_size; </PRE>
<PRE>memory_size = biosmemory(); /* returns value up to 640K */ 
printf(&quot;RAM size = %dK\n&quot;,memory_size); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> biosprint </font>
功 能: 直接使用BIOS服务的打印机I/O 
用 法: int biosprint(int cmd, int byte, int port); 
程序例: </PRE>
<PRE>#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
#define STATUS 2 /* printer status command */ 
#define PORTNUM 0 /* port number for LPT1 */ </PRE>
<PRE>int status, abyte=0; </PRE>
<PRE>printf(&quot;Please turn off your printer. Press any key to continue\n&quot;); 
getch(); 
status = biosprint(STATUS, abyte, PORTNUM); 
if (status &amp; 0x01) 
printf(&quot;Device time out.\n&quot;); 
if (status &amp; 0x08) 
printf(&quot;I/O error.\n&quot;); </PRE>
<PRE>if (status &amp; 0x10) 
printf(&quot;Selected.\n&quot;); 
if (status &amp; 0x20) 
printf(&quot;Out of paper.\n&quot;); </PRE>
<PRE>if (status &amp; 0x40) 
printf(&quot;Acknowledge.\n&quot;); 
if (status &amp; 0x80) 
printf(&quot;Not busy.\n&quot;); </PRE>
<PRE>return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> biostime </font>
功 能: 读取或设置BIOS时间 
用 法: long biostime(int cmd, long newtime); 
程序例: </PRE>
<PRE>#include 
#include 
#include 
#include </PRE>
<PRE>int main(void) 
{ 
long bios_time; </PRE>
<PRE>clrscr(); 
cprintf(&quot;The number of clock ticks since midnight is:\r\n&quot;); 
cprintf(&quot;The number of seconds since midnight is:\r\n&quot;); 
cprintf(&quot;The number of minutes since midnight is:\r\n&quot;); 
cprintf(&quot;The number of hours since midnight is:\r\n&quot;); 
cprintf(&quot;\r\nPress any key to quit:&quot;); 
while(!kbhit()) 
{ 
bios_time = biostime(0, 0L); </PRE>
<PRE>gotoxy(50, 1); 
cprintf(&quot;%lu&quot;, bios_time); </PRE>
<PRE>gotoxy(50, 2); 
cprintf(&quot;%.4f&quot;, bios_time / CLK_TCK); </PRE>
<PRE>gotoxy(50, 3); 
cprintf(&quot;%.4f&quot;, bios_time / CLK_TCK / 60); </PRE>
<PRE>gotoxy(50, 4); 
cprintf(&quot;%.4f&quot;, bios_time / CLK_TCK / 3600); 
} 
return 0; 
} 


</PRE>
<PRE>函数名: <font size="5" color="#FF0000">brk</font> 
功 能: 改变数据段空间分配 
用 法: int brk(void *endds); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>int main(void) 
{ 
char *ptr; </PRE>
<PRE>printf(&quot;Changing allocation with brk()\n&quot;); 
ptr = malloc(1); 
printf(&quot;Before brk() call: %lu bytes free\n&quot;, coreleft()); 
brk(ptr+1000); 
printf(&quot; After brk() call: %lu bytes free\n&quot;, coreleft()); 
return 0; 
} 


</PRE>
<PRE>函数名:<font size="5" color="#FF0000"> bsearch</font> 
功 能: 二分法搜索 
用 法: void *bsearch(const void *key, const void *base, size_t *nelem, 
size_t width, int(*fcmp)(const void *, const *)); 
程序例: </PRE>
<PRE>#include 
#include </PRE>
<PRE>#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0])) </PRE>
<PRE>int numarray[] = {123, 145, 512, 627, 800, 933}; </PRE>
<PRE>int numeric (const int *p1, const int *p2) 
{ 
return(*p1 - *p2); 
} </PRE>
<PRE>int lookup(int key) 
{ 
int *itemptr; </PRE>
<PRE>/* The cast of (int(*)(const void *,const void*)) is needed to avoid a type mismatch error at compile time */ 
</PRE>
<PRE>itemptr = bsearch (&amp;key, numarray, NELEMS(numarray), 
sizeof(int), (int(*)(const void *,const void *))numeric); 
return (itemptr != NULL); 
} </PRE>
<PRE>int main(void) 
{ 
if (lookup(512)) 
printf(&quot;512 is in the table.\n&quot;); 
else 
printf(&quot;512 isn't in the table.\n&quot;); </PRE>
<PRE>return 0; 
} 
</PRE>

<PRE><font size="5"><a href="a.htm">A</a> <a href="b.htm">B</a> <a href="c.htm">C</a> <a href="d.htm">D</a> <a href="e.htm">E</a> <a href="f.htm">F</a> <a href="g.htm">G</a> <a href="h.htm">H</a> <a href="i.htm">I</a> <a href="k.htm">K</a> <a href="l.htm">L</a> <a href="m.htm">M</a> <a href="n.htm">N</a> <a href="o.htm">O</a> <a href="p.htm">P</a> <a href="q.htm">Q</a> <a href="r.htm">R</a> <a href="s.htm">S</a> <a href="t.htm">T</a> <a href="u.htm">U</a> <a href="v.htm">V</a> <a href="w.htm">W</a> </font></PRE>

<pre> </pre>
<pre> </pre>
<pre>资料收集:beck Copyright 2004 张求熙, All Rights Reserved</pre>
<pre><a href="mailto:Email:qiuxi1984@126.com">Email:qiuxi1984@126.com</a>     QQ:35540948 </pre>
<PRE> </PRE>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -