📄 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 bgcolor="#CCCCCC">
<font color="#003399"> </font>
<P><font color="#003399">函数名: bar <BR>
功 能: 画一个二维条形图 <BR>
用 法: void far bar(int left, int top, int right, int bottom); <BR>
程序例: </font>
<P><font color="#003399">#include <graphics.h> <BR>
#include <stdlib.h> <BR>
#include <stdio.h> <BR>
#include <conio.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
/* request auto detection */ <BR>
int gdriver = DETECT, gmode, errorcode; <BR>
int midx, midy, i; </font>
<P><font color="#003399"> /* initialize graphics and local variables
*/ <BR>
initgraph(&gdriver, &gmode, ""); </font>
<P><font color="#003399"> /* 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>
} </font>
<P><font color="#003399"> midx = getmaxx() / 2; <BR>
midy = getmaxy() / 2; </font>
<P><font color="#003399"> /* loop through the fill patterns */ <BR>
for (i=SOLID_FILL; i<USER_FILL; i++) <BR>
{ <BR>
/* set the fill style */ <BR>
setfillstyle(i, getmaxcolor()); </font>
<P><font color="#003399"> /* draw the bar */ <BR>
bar(midx-50, midy-50, midx+50, <BR>
midy+50); </font>
<P><font color="#003399"> getch(); <BR>
} </font>
<P><font color="#003399"> /* clean up */ <BR>
closegraph(); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: bar3d <BR>
功 能: 画一个三维条形图 <BR>
用 法: void far bar3d(int left, int top, int right, int bottom, <BR>
int depth, int topflag); <BR>
程序例: </font>
<P><font color="#003399">#include <graphics.h> <BR>
#include <stdlib.h> <BR>
#include <stdio.h> <BR>
#include <conio.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
/* request auto detection */ <BR>
int gdriver = DETECT, gmode, errorcode; <BR>
int midx, midy, i; </font>
<P><font color="#003399"> /* initialize graphics, local variables
*/ <BR>
initgraph(&gdriver, &gmode, ""); </font>
<P><font color="#003399"> /* 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>
} </font>
<P><font color="#003399"> midx = getmaxx() / 2; <BR>
midy = getmaxy() / 2; </font>
<P><font color="#003399"> /* loop through the fill patterns */ <BR>
for (i=EMPTY_FILL; i<USER_FILL; i++) <BR>
{ <BR>
/* set the fill style */ <BR>
setfillstyle(i, getmaxcolor()); </font>
<P><font color="#003399"> /* draw the 3-d bar */
<BR>
bar3d(midx-50, midy-50, midx+50, midy+50, 10,
1); </font>
<P><font color="#003399"> getch(); <BR>
} </font>
<P><font color="#003399"> /* clean up */ <BR>
closegraph(); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: bdos <BR>
功 能: DOS系统调用 <BR>
用 法: int bdos(int dosfun, unsigned dosdx, unsigned dosal); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <dos.h> </font>
<P><font color="#003399">/* Get current drive as 'A', 'B', ... */ <BR>
char current_drive(void) <BR>
{ <BR>
char curdrive; </font>
<P><font color="#003399"> /* Get current disk as 0, 1, ... */ <BR>
curdrive = bdos(0x19, 0, 0); <BR>
return('A' + curdrive); <BR>
} </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
printf("The current drive is %c:\n", current_drive()); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: bdosptr <BR>
功 能: DOS系统调用 <BR>
用 法: int bdosptr(int dosfun, void *argument, unsigned dosal); <BR>
程序例: </font>
<P><font color="#003399">#include <string.h> <BR>
#include <stdio.h> <BR>
#include <dir.h> <BR>
#include <dos.h> <BR>
#include <errno.h> <BR>
#include <stdlib.h> </font>
<P><font color="#003399">#define BUFLEN 80 </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
char buffer[BUFLEN]; <BR>
int test; </font>
<P><font color="#003399"> printf("Enter full pathname of a directory\n");
<BR>
gets(buffer); </font>
<P><font color="#003399"> 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>
} </font>
<P><font color="#003399"> getcwd(buffer, BUFLEN); <BR>
printf("The current directory is: %s\n", buffer); </font>
<P><font color="#003399"> return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: bioscom <BR>
功 能: 串行I/O通信 <BR>
用 法: int bioscom(int cmd, char abyte, int port); <BR>
程序例: </font>
<P><font color="#003399">#include <bios.h> <BR>
#include <conio.h> </font>
<P><font color="#003399">#define COM1 0 <BR>
#define DATA_READY 0x100 <BR>
#define TRUE 1 <BR>
#define FALSE 0 </font>
<P><font color="#003399">#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00) </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
int in, out, status, DONE = FALSE; </font>
<P><font color="#003399"> 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>
</font>
<P><font color="#003399">函数名: biosdisk <BR>
功 能: 软硬盘I/O <BR>
用 法: int biosdisk(int cmd, int drive, int head, int track, int sector
<BR>
int nsects, void *buffer); <BR>
程序例: </font>
<P><font color="#003399">#include <bios.h> <BR>
#include <stdio.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
int result; <BR>
char buffer[512]; </font>
<P><font color="#003399"> 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")); </font>
<P><font color="#003399"> return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: biosequip <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -