📄 fb.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="Author" content="wdg">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>网上学堂 --> C语言编程宝典之一 -->函数名: b</title>
</head>
<body>
<div align="center"><center>
<table border="1" cellpadding="4" width="640"
bordercolordark="#FFFFFF" bordercolorlight="#FFFFFF">
<tr>
<td bgcolor="#FFE6B0" bordercolor="#8080FF" class="p9"><font
color="#BB0000">导航条:--></font> <a
href="../../index.html">网上学堂</a> --> <a
href="../tcindex.htm"><font face="宋体">C</font>语言编程宝典之一</a>
-->函数名: b</td>
</tr>
<tr>
<td bordercolor="#8080FF" class="p9">函数名: 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>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy, i; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<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>
<p> /* draw the bar */ <br>
bar(midx-50, midy-50,
midx+50, <br>
midy+50); </p>
<p> getch(); <br>
} </p>
<p> /* clean up */ <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: bar3d <br>
功 能: 画一个三维条形图 <br>
用 法: void far bar3d(int left, int top, int
right, int bottom, <br>
int depth, int topflag); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy, i; </p>
<p> /* initialize graphics, local variables
*/ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<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>
<p> /* draw the 3-d bar */ <br>
bar3d(midx-50, midy-50,
midx+50, midy+50, 10, 1); </p>
<p> getch(); <br>
} </p>
<p> /* clean up */ <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: bdos <br>
功 能: DOS系统调用 <br>
用 法: int bdos(int dosfun, unsigned dosdx,
unsigned dosal); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dos.h> </p>
<p>/* Get current drive as 'A', 'B', ... */ <br>
char current_drive(void) <br>
{ <br>
char curdrive; </p>
<p> /* Get current disk as 0, 1, ... */ <br>
curdrive = bdos(0x19, 0, 0); <br>
return('A' + curdrive); <br>
} </p>
<p>int main(void) <br>
{ <br>
printf("The current drive is
%c:\n", current_drive()); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: bdosptr <br>
功 能: DOS系统调用 <br>
用 法: int bdosptr(int dosfun, void *argument,
unsigned dosal); <br>
程序例: </p>
<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>
<p>#define BUFLEN 80 </p>
<p>int main(void) <br>
{ <br>
char buffer[BUFLEN]; <br>
int test; </p>
<p> printf("Enter full pathname of a
directory\n"); <br>
gets(buffer); </p>
<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>
<p> getcwd(buffer, BUFLEN); <br>
printf("The current directory is:
%s\n", buffer); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: bioscom <br>
功 能: 串行I/O通信 <br>
用 法: int bioscom(int cmd, char abyte, int
port); <br>
程序例: </p>
<p>#include <bios.h> <br>
#include <conio.h> </p>
<p>#define COM1 0 <br>
#define DATA_READY 0x100 <br>
#define TRUE 1 <br>
#define FALSE 0 </p>
<p>#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00) </p>
<p>int main(void) <br>
{ <br>
int in, out, status, DONE = FALSE; </p>
<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>
<p>函数名: biosdisk <br>
功 能: 软硬盘I/O <br>
用 法: int biosdisk(int cmd, int drive, int head,
int track, int sector <br>
int nsects, void
*buffer); <br>
程序例: </p>
<p>#include <bios.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
int result; <br>
char buffer[512]; </p>
<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>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: biosequip <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -