⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fb.htm

📁 C函数速查。很有用的手册。相信会对大家的编程有用。
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<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">&nbsp; </font>
<P><font color="#003399">函数名: bar <BR>
  功&nbsp; 能: 画一个二维条形图 <BR>
  用&nbsp; 法: void far bar(int left, int top, int right, int bottom); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;graphics.h> <BR>
  #include &lt;stdlib.h> <BR>
  #include &lt;stdio.h> <BR>
  #include &lt;conio.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; /* request auto detection */ <BR>
  &nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode; <BR>
  &nbsp;&nbsp; int midx, midy, i; </font>
<P><font color="#003399">&nbsp;&nbsp; /* initialize graphics and local variables 
  */ <BR>
  &nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, ""); </font>
<P><font color="#003399">&nbsp;&nbsp; /* read result of initialization */ <BR>
  &nbsp;&nbsp; errorcode = graphresult(); <BR>
  &nbsp;&nbsp; if (errorcode != grOk)&nbsp; /* an error occurred */ <BR>
  &nbsp;&nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
  <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:"); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch(); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1); /* terminate with an error code */ <BR>
  &nbsp;&nbsp; } </font>
<P><font color="#003399">&nbsp;&nbsp; midx = getmaxx() / 2; <BR>
  &nbsp;&nbsp; midy = getmaxy() / 2; </font>
<P><font color="#003399">&nbsp;&nbsp; /* loop through the fill patterns */ <BR>
  &nbsp;&nbsp; for (i=SOLID_FILL; i&lt;USER_FILL; i++) <BR>
  &nbsp;&nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* set the fill style */ <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setfillstyle(i, getmaxcolor()); </font>
<P><font color="#003399">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* draw the bar */ <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bar(midx-50, midy-50, midx+50, <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; midy+50); </font>
<P><font color="#003399">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch(); <BR>
  &nbsp;&nbsp; } </font>
<P><font color="#003399">&nbsp;&nbsp; /* clean up */ <BR>
  &nbsp;&nbsp; closegraph(); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: bar3d <BR>
  功&nbsp; 能: 画一个三维条形图 <BR>
  用&nbsp; 法: void far bar3d(int left, int top, int right, int bottom, <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  int depth, int topflag); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;graphics.h> <BR>
  #include &lt;stdlib.h> <BR>
  #include &lt;stdio.h> <BR>
  #include &lt;conio.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; /* request auto detection */ <BR>
  &nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode; <BR>
  &nbsp;&nbsp; int midx, midy, i; </font>
<P><font color="#003399">&nbsp;&nbsp; /* initialize graphics, local variables 
  */ <BR>
  &nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, ""); </font>
<P><font color="#003399">&nbsp;&nbsp; /* read result of initialization */ <BR>
  &nbsp;&nbsp; errorcode = graphresult(); <BR>
  &nbsp;&nbsp; if (errorcode != grOk)&nbsp; /* an error occurred */ <BR>
  &nbsp;&nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
  <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:"); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch(); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1); /* terminate with error code */ <BR>
  &nbsp;&nbsp; } </font>
<P><font color="#003399">&nbsp;&nbsp; midx = getmaxx() / 2; <BR>
  &nbsp;&nbsp; midy = getmaxy() / 2; </font>
<P><font color="#003399">&nbsp;&nbsp; /* loop through the fill patterns */ <BR>
  &nbsp;&nbsp; for (i=EMPTY_FILL; i&lt;USER_FILL; i++) <BR>
  &nbsp;&nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* set the fill style */ <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setfillstyle(i, getmaxcolor()); </font>
<P><font color="#003399">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* draw the 3-d bar */ 
  <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bar3d(midx-50, midy-50, midx+50, midy+50, 10, 
  1); </font>
<P><font color="#003399">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch(); <BR>
  &nbsp;&nbsp; } </font>
<P><font color="#003399">&nbsp;&nbsp; /* clean up */ <BR>
  &nbsp;&nbsp; closegraph(); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: bdos <BR>
  功&nbsp; 能: DOS系统调用 <BR>
  用&nbsp; 法: int bdos(int dosfun, unsigned dosdx, unsigned dosal); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;stdio.h> <BR>
  #include &lt;dos.h> </font>
<P><font color="#003399">/* Get current drive as 'A', 'B', ... */ <BR>
  char current_drive(void) <BR>
  { <BR>
  &nbsp;&nbsp; char curdrive; </font>
<P><font color="#003399">&nbsp;&nbsp; /* Get current disk as 0, 1, ... */ <BR>
  &nbsp;&nbsp; curdrive = bdos(0x19, 0, 0); <BR>
  &nbsp;&nbsp; return('A' + curdrive); <BR>
  } </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; printf("The current drive is %c:\n", current_drive()); <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: bdosptr <BR>
  功&nbsp; 能: DOS系统调用 <BR>
  用&nbsp; 法: int bdosptr(int dosfun, void *argument, unsigned dosal); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;string.h> <BR>
  #include &lt;stdio.h> <BR>
  #include &lt;dir.h> <BR>
  #include &lt;dos.h> <BR>
  #include &lt;errno.h> <BR>
  #include &lt;stdlib.h> </font>
<P><font color="#003399">#define&nbsp; BUFLEN&nbsp; 80 </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; char&nbsp; buffer[BUFLEN]; <BR>
  &nbsp;&nbsp; int&nbsp;&nbsp; test; </font>
<P><font color="#003399">&nbsp;&nbsp; printf("Enter full pathname of a directory\n"); 
  <BR>
  &nbsp;&nbsp; gets(buffer); </font>
<P><font color="#003399">&nbsp;&nbsp; test = bdosptr(0x3B,buffer,0); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(test) <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>
  &nbsp; printf("DOS error message: %d\n", errno); <BR>
  &nbsp; /* See errno.h for error listings */ <BR>
  &nbsp; exit (1); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </font>
<P><font color="#003399">&nbsp;&nbsp; getcwd(buffer, BUFLEN); <BR>
  &nbsp;&nbsp; printf("The current directory is: %s\n", buffer); </font>
<P><font color="#003399">&nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: bioscom <BR>
  功&nbsp; 能: 串行I/O通信 <BR>
  用&nbsp; 法: int bioscom(int cmd, char abyte, int port); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;bios.h> <BR>
  #include &lt;conio.h> </font>
<P><font color="#003399">#define COM1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 <BR>
  #define DATA_READY 0x100 <BR>
  #define TRUE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 <BR>
  #define FALSE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 </font>
<P><font color="#003399">#define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00) </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; int in, out, status, DONE = FALSE; </font>
<P><font color="#003399">&nbsp;&nbsp; bioscom(0, SETTINGS, COM1); <BR>
  &nbsp;&nbsp; cprintf("... BIOSCOM [ESC] to exit ...\n"); <BR>
  &nbsp;&nbsp; while (!DONE) <BR>
  &nbsp;&nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status = bioscom(3, 0, COM1); <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (status &amp; DATA_READY) <BR>
  &nbsp; if ((out = bioscom(2, 0, COM1) &amp; 0x7F) != 0) <BR>
  &nbsp;&nbsp;&nbsp;&nbsp; putch(out); <BR>
  &nbsp; if (kbhit()) <BR>
  &nbsp; { <BR>
  &nbsp;&nbsp;&nbsp;&nbsp; if ((in = getch()) == '\x1B') <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DONE = TRUE; <BR>
  &nbsp;&nbsp;&nbsp;&nbsp; bioscom(1, in, COM1); <BR>
  &nbsp; } <BR>
  &nbsp;&nbsp; } <BR>
  &nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: biosdisk <BR>
  功&nbsp; 能: 软硬盘I/O <BR>
  用&nbsp; 法: int biosdisk(int cmd, int drive, int head, int track, int sector 
  <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int nsects, void *buffer); <BR>
  程序例: </font>
<P><font color="#003399">#include &lt;bios.h> <BR>
  #include &lt;stdio.h> </font>
<P><font color="#003399">int main(void) <BR>
  { <BR>
  &nbsp;&nbsp; int result; <BR>
  &nbsp;&nbsp; char buffer[512]; </font>
<P><font color="#003399">&nbsp;&nbsp; printf("Testing to see if drive a: is ready\n"); 
  <BR>
  &nbsp;&nbsp; result = biosdisk(4,0,0,0,0,1,buffer); <BR>
  &nbsp;&nbsp; result &amp;= 0x02; <BR>
  &nbsp;&nbsp; (result) ? (printf("Drive A: Ready\n")) : <BR>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (printf("Drive A: Not Ready\n")); </font>
<P><font color="#003399">&nbsp;&nbsp; return 0; <BR>
  } <BR>
  &nbsp; <BR>
  &nbsp; <BR>
  &nbsp; </font>
<P><font color="#003399">函数名: biosequip <BR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -