?? fb.htm
字號:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<META NAME="Author" CONTENT="wdg">
<META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]">
<TITLE>fb</TITLE>
</HEAD>
<BODY>
<P>函數(shù)名: bar
<BR>功 能: 畫一個二維條形圖
<BR>用 法: void far bar(int left, int top, int right, int bottom);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int midx, midy, i;
<P> /* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P> /* read result of initialization */
<BR> errorcode = graphresult();
<BR> if (errorcode != grOk) /* an error occurred */
<BR> {
<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR> exit(1); /* terminate with an error
code */
<BR> }
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<P> /* loop through the fill patterns */
<BR> for (i=SOLID_FILL; i<USER_FILL; i++)
<BR> {
<BR> /* set the fill style */
<BR> setfillstyle(i, getmaxcolor());
<P> /* draw the bar */
<BR> bar(midx-50, midy-50, midx+50,
<BR> midy+50);
<P> getch();
<BR> }
<P> /* clean up */
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: bar3d
<BR>功 能: 畫一個三維條形圖
<BR>用 法: void far bar3d(int left, int top, int right, int bottom,
<BR>
int depth, int topflag);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> int midx, midy, i;
<P> /* initialize graphics, local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P> /* read result of initialization */
<BR> errorcode = graphresult();
<BR> if (errorcode != grOk) /* an error occurred */
<BR> {
<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR> exit(1); /* terminate with error code
*/
<BR> }
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<P> /* loop through the fill patterns */
<BR> for (i=EMPTY_FILL; i<USER_FILL; i++)
<BR> {
<BR> /* set the fill style */
<BR> setfillstyle(i, getmaxcolor());
<P> /* draw the 3-d bar */
<BR> bar3d(midx-50, midy-50, midx+50, midy+50,
10, 1);
<P> getch();
<BR> }
<P> /* clean up */
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: bdos
<BR>功 能: DOS系統(tǒng)調(diào)用
<BR>用 法: int bdos(int dosfun, unsigned dosdx, unsigned dosal);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>/* Get current drive as 'A', 'B', ... */
<BR>char current_drive(void)
<BR>{
<BR> char curdrive;
<P> /* Get current disk as 0, 1, ... */
<BR> curdrive = bdos(0x19, 0, 0);
<BR> return('A' + curdrive);
<BR>}
<P>int main(void)
<BR>{
<BR> printf("The current drive is %c:\n", current_drive());
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: bdosptr
<BR>功 能: DOS系統(tǒng)調(diào)用
<BR>用 法: int bdosptr(int dosfun, void *argument, unsigned dosal);
<BR>程序例:
<P>#include <string.h>
<BR>#include <stdio.h>
<BR>#include <dir.h>
<BR>#include <dos.h>
<BR>#include <errno.h>
<BR>#include <stdlib.h>
<P>#define BUFLEN 80
<P>int main(void)
<BR>{
<BR> char buffer[BUFLEN];
<BR> int test;
<P> printf("Enter full pathname of a directory\n");
<BR> gets(buffer);
<P> test = bdosptr(0x3B,buffer,0);
<BR> if(test)
<BR> {
<BR> printf("DOS error message: %d\n", errno);
<BR> /* See errno.h for error listings */
<BR> exit (1);
<BR> }
<P> getcwd(buffer, BUFLEN);
<BR> printf("The current directory is: %s\n", buffer);
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: bioscom
<BR>功 能: 串行I/O通信
<BR>用 法: int bioscom(int cmd, char abyte, int port);
<BR>程序例:
<P>#include <bios.h>
<BR>#include <conio.h>
<P>#define COM1 0
<BR>#define DATA_READY 0x100
<BR>#define TRUE 1
<BR>#define FALSE 0
<P>#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)
<P>int main(void)
<BR>{
<BR> int in, out, status, DONE = FALSE;
<P> bioscom(0, SETTINGS, COM1);
<BR> cprintf("... BIOSCOM [ESC] to exit ...\n");
<BR> while (!DONE)
<BR> {
<BR> status = bioscom(3, 0, COM1);
<BR> if (status & DATA_READY)
<BR> if ((out = bioscom(2, 0, COM1) & 0x7F) != 0)
<BR> putch(out);
<BR> if (kbhit())
<BR> {
<BR> if ((in = getch()) == '\x1B')
<BR> DONE = TRUE;
<BR> bioscom(1, in, COM1);
<BR> }
<BR> }
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: biosdisk
<BR>功 能: 軟硬盤I/O
<BR>用 法: int biosdisk(int cmd, int drive, int head, int track,
int sector
<BR> int nsects, void *buffer);
<BR>程序例:
<P>#include <bios.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> int result;
<BR> char buffer[512];
<P> printf("Testing to see if drive a: is ready\n");
<BR> result = biosdisk(4,0,0,0,0,1,buffer);
<BR> result &= 0x02;
<BR> (result) ? (printf("Drive A: Ready\n")) :
<BR> (printf("Drive A: Not Ready\n"));
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: biosequip
<BR>功 能: 檢查設備
<BR>用 法: int biosequip(void);
<BR>程序例:
<P>#include <bios.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> int result;
<BR> char buffer[512];
<P> printf("Testing to see if drive a: is ready\n");
<BR> result = biosdisk(4,0,0,0,0,1,buffer);
<BR> result &= 0x02;
<BR> (result) ? (printf("Drive A: Ready\n")) :
<BR> (printf("Drive A: Not Ready\n"));
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: bioskey
<BR>功 能: 直接使用BIOS服務的鍵盤接口
<BR>用 法: int bioskey(int cmd);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <bios.h>
<BR>#include <ctype.h>
<P>#define RIGHT 0x01
<BR>#define LEFT 0x02
<BR>#define CTRL 0x04
<BR>#define ALT 0x08
<P>int main(void)
<BR>{
<BR> int key, modifiers;
<P> /* function 1 returns 0 until a key is pressed */
<BR> while (bioskey(1) == 0);
<P> /* function 0 returns the key that is waiting */
<BR> key = bioskey(0);
<P> /* use function 2 to determine if shift keys were used
*/
<BR> modifiers = bioskey(2);
<BR> if (modifiers)
<BR> {
<BR> printf("[");
<BR> if (modifiers & RIGHT) printf("RIGHT");
<BR> if (modifiers & LEFT) printf("LEFT");
<BR> if (modifiers & CTRL) printf("CTRL");
<BR> if (modifiers & ALT)
printf("ALT");
<BR> printf("]");
<BR> }
<BR> /* print out the character read */
<BR> if (isalnum(key & 0xFF))
<BR> printf("'%c'\n", key);
<BR> else
<BR> printf("%#02x\n", key);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: biosmemory
<BR>功 能: 返回存儲塊大小
<BR>用 法:int biosmemory(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <bios.h>
<P>int main(void)
<BR>{
<BR> int memory_size;
<P> memory_size = biosmemory(); /* returns value up to
640K */
<BR> printf("RAM size = %dK\n",memory_size);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: biosprint
<BR>功 能: 直接使用BIOS服務的打印機I/O
<BR>用 法: int biosprint(int cmd, int byte, int port);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <conio.h>
<BR>#include <bios.h>
<P>int main(void)
<BR>{
<BR> #define STATUS 2 /* printer status
command */
<BR> #define PORTNUM 0 /* port number for
LPT1 */
<P> int status, abyte=0;
<P> printf("Please turn off your printer. Press any key
to continue\n");
<BR> getch();
<BR> status = biosprint(STATUS, abyte, PORTNUM);
<BR> if (status & 0x01)
<BR> printf("Device time out.\n");
<BR> if (status & 0x08)
<BR> printf("I/O error.\n");
<P> if (status & 0x10)
<BR> printf("Selected.\n");
<BR> if (status & 0x20)
<BR> printf("Out of paper.\n");
<P> if (status & 0x40)
<BR> printf("Acknowledge.\n");
<BR> if (status & 0x80)
<BR> printf("Not busy.\n");
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: biostime
<BR>功 能: 讀取或設置BIOS時間
<BR>用 法: long biostime(int cmd, long newtime);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <bios.h>
<BR>#include <time.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> long bios_time;
<P> clrscr();
<BR> cprintf("The number of clock ticks since midnight is:\r\n");
<BR> cprintf("The number of seconds since midnight is:\r\n");
<BR> cprintf("The number of minutes since midnight is:\r\n");
<BR> cprintf("The number of hours since midnight is:\r\n");
<BR> cprintf("\r\nPress any key to quit:");
<BR> while(!kbhit())
<BR> {
<BR> bios_time = biostime(0, 0L);
<P> gotoxy(50, 1);
<BR> cprintf("%lu", bios_time);
<P> gotoxy(50, 2);
<BR> cprintf("%.4f", bios_time / CLK_TCK);
<P> gotoxy(50, 3);
<BR> cprintf("%.4f", bios_time / CLK_TCK
/ 60);
<P> gotoxy(50, 4);
<BR> cprintf("%.4f", bios_time / CLK_TCK
/ 3600);
<BR> }
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: brk
<BR>功 能: 改變數(shù)據(jù)段空間分配
<BR>用 法: int brk(void *endds);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <alloc.h>
<P>int main(void)
<BR>{
<BR> char *ptr;
<P> printf("Changing allocation with brk()\n");
<BR> ptr = malloc(1);
<BR> printf("Before brk() call: %lu bytes free\n", coreleft());
<BR> brk(ptr+1000);
<BR> printf(" After brk() call: %lu bytes free\n", coreleft());
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: bsearch
<BR>功 能: 二分法搜索
<BR>用 法: void *bsearch(const void *key, const void *base, size_t
*nelem,
<BR> size_t width, int(*fcmp)(const
void *, const *));
<BR>程序例:
<P>#include <stdlib.h>
<BR>#include <stdio.h>
<P>#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
<P>int numarray[] = {123, 145, 512, 627, 800, 933};
<P>int numeric (const int *p1, const int *p2)
<BR>{
<BR> return(*p1 - *p2);
<BR>}
<P>int lookup(int key)
<BR>{
<BR> int *itemptr;
<P> /* The cast of (int(*)(const void *,const void*))
<BR> is needed to avoid a type mismatch error
at
<BR> compile time */
<BR> itemptr = bsearch (&key, numarray, NELEMS(numarray),
<BR> sizeof(int), (int(*)(const void *,const
void *))numeric);
<BR> return (itemptr != NULL);
<BR>}
<P>int main(void)
<BR>{
<BR> if (lookup(512))
<BR> printf("512 is in the table.\n");
<BR> else
<BR> printf("512 isn't in the table.\n");
<P> return 0;
<BR>}
<BR>
<P>
<A HREF="index.html">返回目錄</A>
<P>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -