📄 fb.htm
字号:
功 能: 检查设备 <BR>
用 法: int biosequip(void); <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">函数名: bioskey <BR>
功 能: 直接使用BIOS服务的键盘接口 <BR>
用 法: int bioskey(int cmd); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <bios.h> <BR>
#include <ctype.h> </font>
<P><font color="#003399">#define RIGHT 0x01 <BR>
#define LEFT 0x02 <BR>
#define CTRL 0x04 <BR>
#define ALT 0x08 </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
int key, modifiers; </font>
<P><font color="#003399"> /* function 1 returns 0 until a key is pressed
*/ <BR>
while (bioskey(1) == 0); </font>
<P><font color="#003399"> /* function 0 returns the key that is waiting
*/ <BR>
key = bioskey(0); </font>
<P><font color="#003399"> /* 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>
</font>
<P><font color="#003399">函数名: biosmemory <BR>
功 能: 返回存储块大小 <BR>
用 法:int biosmemory(void); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <bios.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
int memory_size; </font>
<P><font color="#003399"> memory_size = biosmemory(); /* returns
value up to 640K */ <BR>
printf("RAM size = %dK\n",memory_size); <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: biosprint <BR>
功 能: 直接使用BIOS服务的打印机I/O <BR>
用 法: int biosprint(int cmd, int byte, int port); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <conio.h> <BR>
#include <bios.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
#define STATUS 2 /* printer status command
*/ <BR>
#define PORTNUM 0 /* port number for LPT1 */
</font>
<P><font color="#003399"> int status, abyte=0; </font>
<P><font color="#003399"> 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"); </font>
<P><font color="#003399"> if (status & 0x10) <BR>
printf("Selected.\n"); <BR>
if (status & 0x20) <BR>
printf("Out of paper.\n"); </font>
<P><font color="#003399"> if (status & 0x40) <BR>
printf("Acknowledge.\n"); <BR>
if (status & 0x80) <BR>
printf("Not busy.\n"); </font>
<P><font color="#003399"> return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: biostime <BR>
功 能: 读取或设置BIOS时间 <BR>
用 法: long biostime(int cmd, long newtime); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <bios.h> <BR>
#include <time.h> <BR>
#include <conio.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
long bios_time; </font>
<P><font color="#003399"> 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); </font>
<P><font color="#003399"> gotoxy(50, 1); <BR>
cprintf("%lu", bios_time); </font>
<P><font color="#003399"> gotoxy(50, 2); <BR>
cprintf("%.4f", bios_time / CLK_TCK); </font>
<P><font color="#003399"> gotoxy(50, 3); <BR>
cprintf("%.4f", bios_time / CLK_TCK / 60); </font>
<P><font color="#003399"> gotoxy(50, 4); <BR>
cprintf("%.4f", bios_time / CLK_TCK / 3600);
<BR>
} <BR>
return 0; <BR>
} <BR>
<BR>
<BR>
</font>
<P><font color="#003399">函数名: brk <BR>
功 能: 改变数据段空间分配 <BR>
用 法: int brk(void *endds); <BR>
程序例: </font>
<P><font color="#003399">#include <stdio.h> <BR>
#include <alloc.h> </font>
<P><font color="#003399">int main(void) <BR>
{ <BR>
char *ptr; </font>
<P><font color="#003399"> 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>
</font>
<P><font color="#003399">函数名: bsearch <BR>
功 能: 二分法搜索 <BR>
用 法: void *bsearch(const void *key, const void *base, size_t *nelem, <BR>
size_t width, int(*fcmp)(const void
*, const *)); <BR>
程序例: </font>
<P><font color="#003399">#include <stdlib.h> <BR>
#include <stdio.h> </font>
<P><font color="#003399">#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0])) </font>
<P><font color="#003399">int numarray[] = {123, 145, 512, 627, 800, 933}; </font>
<P><font color="#003399">int numeric (const int *p1, const int *p2) <BR>
{ <BR>
return(*p1 - *p2); <BR>
} </font>
<P><font color="#003399">int lookup(int key) <BR>
{ <BR>
int *itemptr; </font>
<P><font color="#003399"> /* 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>
} </font>
<P><font color="#003399">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"); </font>
<P><font color="#003399"> return 0; <BR>
} <BR>
</font>
<P><font color="#003399">
<A HREF="cyyhsdq.htm">返回</A></font>
<P><font color="#003399"> </font>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -