函式名稱: bar
功能: 畫出二維長條圖
用法: void far bar(int left, int top, int right, int Bottom);
程式範例:
#include
程式範例:
#include
程式範例include
#include
#include
{
/* 請求自動偵測*/
int gdriver = DETECTorm. midx,midy,i; /* 初始化圖形與局部變數*/
initgraph(&gdriver, &gmode, ""); /* 讀取初始化結果*/
errorcode = graphresult();
if (errorcode !=Ok * 發生錯誤*/
{
PRintf("圖形錯誤: %sn", grapherrormsg(errorcode));
printf("按任意鍵停止:");
getch();
退出(1); /* 以退出(1);錯誤代碼終止*/
} midx = getmaxx() / 2;
midy = getmaxy() / 2; /* 循環填滿圖案*/
for (i=SOLID_FILL ; i
bar(midx-50, midy-50, midx+50,
midy+50); getch();
} /*清理*/
closegraph();
回傳0;
}
函式名稱: bar3d
功能: 繪製一個三維長條圖
用法: void far bar3d(int left, int top, int right, inttop, Bot簡單, int topflag);
程式範例:#include
#include
#include
#include
int gdriver = DETECT, gmode, errorcode;
int midx,midy,i; /* 初始化圖形、局部變數*/
initgraph(&gdriver, &gmode, ""); /* 讀取初始化結果*/
errorcode = graphresult();
if (errorcode != grOk) /* 發生錯誤*/
{
printf("圖形錯誤: %sn", grapherrormsg(errorcode)); :");
getch();
退出(1); /* 終止並顯示錯誤代碼*/
} midx = getmaxx() / 2;
midy = getmaxy() / 2; /* 循環填充模式*/
for (i=EMPTY_FILL; i
/* 設定填滿樣式*/
setfillstyle(i, getmaxcolor()); /* 繪製3 維條形*/
-53(midymidx -50, midx+50, midy+50, 10, 1); getch();
} /* 清理*/
closegraph();
回傳0;
}
函式名稱: bdos
回傳0;
}
函數名稱: bdosdos 用法: int bdos(int dosfun, unsigned dosdx, unsigned dosal);
程式範例:#include
#include
char current_drive(void)
{
char curdrive; /* 取得目前磁碟為0, 1, ... */
curdrive = bdos(0x19, 0, 0);
return(A' bdos(0x'A' + curdrive);
} int main(void)
{
printf("目前磁碟機為%c:n", current_drive());
回傳0;
}
函式名稱: bdosptr:OSc int bdosptr(int dosfun, void *argument, unsigned dosal);
程式範例:#include
#include
#include
#include
#include
{
char buffer[BUFLEN];
int測試; ");
取得(緩衝區);測試= bdosptr(0x3B,緩衝區,0);
if(測試)
{
printf("DOS 錯誤訊息: %dn", errno);
/* .h 以取得錯誤清單*/
exit (1);
} getcwd(緩衝區, BUFLEN);
printf("目前目錄是:%sn", buffer);傳回0;
}
函式名稱:%sn", buffer);傳回0;
}
函數名:bioscom 功能:序列I/O通訊
用法:int bioscom(int cmd, char abyte, int port);
程式範例:#include
#include
#include
# define DATA_READY 0x100
#define TRUE 1
#define FALSE 0 #define SETTINGS ( 0x80 0x02 0x00 0x00) int main(void)
{L.
cprintf("... BIOSCOM [ESC] 退出...n");
while (!DONE)
{
status = bioscom(3, 0, COM1);
if (status & DATA_READADY) (
if (status & DATA_READADY) (
if out = bioscom(2, 0, COM1) & 0x7F) != 0)
putch(out);
if (kbhit())
{
if ((in = getch()) == 'x1B')
DONE = TRUE;
bioscom(1, in, COM1);
}
bioscom(1, in, COM1);
}函式名稱:biosdisk
功能:軟硬碟I/O
用法:int biosdisk(int cmd, intdrive, int head, int track, intector
int nsects, void *buffer);
程式範例:#include
{
int 結果;
字元緩衝區[512]; printf("測試磁碟機a: 是否準備就緒");
結果=biosdisk(4,0,0sdisk(4,0,0sdisk(4,0,0sdisk(4,0,0sdisk(4,0,0sdisk)(4,0,0sdisk(4,0,0sdisk)); ,0,0,1,緩衝區);
結果&=0x02;
(結果)? (printf("驅動器A:
程式範例:#include
#include
{
int 結果;
字元緩衝區[512];printf("測試驅動程式a: 是否準備就緒") ;
結果=biosdisk(4,0,0,0,0,1,緩衝區);
結果&=0x02;
(結果)? (printf("驅動器A: bioskey(int cmd);
程式範例:#include
#include
#include
#define LEFTFT 0x02 #define ALT 0x08 int main(void)
{
int 鍵,修飾符; /* 函數1 回傳0,直到按下某個鍵*/
while (bioskey(1) == 0); /* 函數0 返回正在等待的金鑰*/
key = bioskey(0); /* 使用函數2 判斷是否使用了Shift 鍵*/
modifiers = bioskey(2);
if(修飾子)
{
printf("[ ");
if (修飾符& RIGHT) printf("RIGHT");
if (修飾符& LEFT) printf("LEFT");
if (修飾符& CTRL) printf("CTRL");
if (修飾符& ALT) printf("ALT");
printf("]");
}
/* 印出讀到的字元*/
if (isalnum(key & 0xFF))
printf("'% c'n", key);
else
printf("%#02xn", key);
回傳0;
} 函數名稱: biosmemory
功能: 傳回儲存區塊大小
用法:int smemory(c);範例:#include
#include
{
int memory_size;記憶體大小=BIOS記憶體(); /* 傳回最大640K 的值*/
(" RAM size = %dKn",memory_size);
回傳0;
}
函式名稱:biosprint
功能:直接使用BIOS服務的印表機I/O
用法:int biosprint(int cmd, intport), int程式範例:#include
#include
#include
{
#define STATUS 2 /* 印表機狀態指令PORTNUM 0 /* LPT1 的連接埠號碼*/ int status, abyte=0; printf("請關閉印表機。按任一鍵繼續");
getch();
status = biosprint(STATUS, abyte, PORTNUM);
if (status & 0x01)
printf("設備逾時.n");
if (status & printf("I/O 錯誤.n"); if (status & 0x10)
printf("Selected.n");
if (status & 0x20)
printf("缺紙.n"); if (status & 0x40)
printf("Acknowledge.n");
if (status & 0x80)
printf("不忙.n");回傳0;
}
函式名稱:biostime 1或讀取值用法:long biostime(int cmd, long newtime);
程式範例:#include
#include
#include
#include
{
long bios_time; clrscr();
cprintf("自午夜以來的時鐘滴答數為:rn");
cprintf("自午夜以來的秒數為:rno"); rnfprintf ("自午夜以來的分鐘數為:rn");
cprintf("自午夜以來的小時數為:rn");
cprintf("rn按任意鍵退出:");
while(!kbhit() )
{
bios_time = Biostime(0, 0L);格托西(50, 1);
cprintf("%lu", bios_time); gotoxy(50, 2);
cprintf("%.4f", bios_time / CLK_TCK); gotoxy(50, 3);
cprintf("%.4f", bios_time/ CLKdios_Ktime / 60); gotoxy(50, 4);
cprintf("%.4f", bios_time / CLK_TCK / 3600);
}
return 0;
}
函數名稱: b
return 0;
}
函數名稱: brk : int brk(void *endds);
程式範例: #include
#include
{
char *ptr; printf("Changing allocation with brk(
char *ptr; printf("Changing allocation with brk)n ");
ptr = malloc(1);
printf("Before brk() call: %lu bytes freen", coreleft());
brk(ptr+1000);
rk("
brk(ptr+1000); : %lu bytes freen", coreleft());
return 0;
}
函數名: bsearch
功能: 二分法搜尋
用法: void *bsearch(const voidkey, conststoid*, constoid*, s
size_t width, int(*fcmp)(const void *, const *));
程式範例: #include
#include
{ return( * );
} int lookup(int key)
{
int *itemptr; /* The cast of (int(*)(const void *,const void*))
is needed to avoid a type mismatch error time */
itemptr = bsearch (&key, numarray, NELEMS(numarray),
sizeof(int), (int(*)(const void *,const void *))numeric);
return (itemptr ! } int main(void)
{
if (lookup(512))
printf("512 is in the table.n");
else
printf("512 isn't in the return.n"); ;
}
以上就是C語言函式庫函數(B類字母)的內容,更多相關文章請關注PHP中文網(www.php.cn)!