【正文】
C 語言庫函數(shù) (O類字母 ) 函數(shù)名 : open 功 能 : 打開一個文件用于讀或?qū)? 用 法 : int open(char *pathname, int access[, int permiss])。 程序例 : include include include include int main(void) { int handle。 char msg[] = Hello world。 if ((handle = open(TEST.$$$, O_CREAT | O_TEXT)) == 1) { perror(Error:)。 return 1。 } write(handle, msg, strlen(msg))。 close(handle)。 return 0。 } 函數(shù)名 : outport 功 能 : 輸出整數(shù)到硬件端口中 用 法 : void outport(int port, int value)。 程序例 : include include int main(void) { int value = 64。 int port = 0。 outportb(port, value)。 printf(Value %d sent to port number %d\n, value, port)。 return 0。 } 函數(shù)名 : outportb 功 能 : 輸出字節(jié)到硬件端口中 用 法 : void outportb(int port, char byte)。 程序例 : include include int main(void) { int value = 64。 int port = 0。 outportb(port, value)。 printf(Value %d sent to port number %d\n, value, port)。 return 0。 } 函數(shù)名 : outtext 功 能 : 在視區(qū)顯示一個字符串 用 法 : void far outtext(char far *textstring)。 程序例 : include include include include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode。 int midx, midy。 /* initialize graphics and local variables */ initgraph(amp。gdriver, amp。gmode, )。 /* read result of initialization */ errorcode = graphresult()。 if (errorcode != grOk) /* an error occurred */ { printf(Graphics error: %s\n, grapherrormsg(errorcode))。 printf(Press any key to halt:)。 getch()。 exit(1)。 /* terminate with an error code */ } midx = getmaxx() / 2。 midy = getmaxy() / 2。 /* move the . to the center of the screen */ moveto(midx, midy)。 /* output text starting at the . */ outtext(This )。 outtext(is )。 outtext(a )。 outtext(test.)。 /* clean up */ getch()。 closegraph()。 return 0。 } 函數(shù)名 : outtextxy 功 能 : 在指定位置顯示一字符串 用 法 : void far outtextxy(int x, int y, char *textstring)。 程序例 : include include include include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode。 int midx, midy。 /* initialize graphics and local variables */ initgraph( amp。gdriver, amp。gmode, )。 /* read result of initialization */ errorcode = graphresult()。 if (errorcode != grOk) /* an error occurred */ { printf(Graphics error: %s\n, grapherrormsg(errorcode))。 printf(Press any key to halt:)。 getch()。 exit(1)。 /* terminate with an error code */ } midx = getmaxx() / 2。 midy = getmaxy() / 2。 /* output text at the center of the screen*/ /* Note: the . doesn39。t get changed.*/ outtextxy(midx, midy, This is a test.)。 /* clean up */ getch()。 closegraph()。 return 0。 } C 語言庫函數(shù) (P類字母 ) 函數(shù)名 : parsfnm 功 能 : 分析文件名 用 法 : char *parsfnm (char *cmdline, struct fcb *fcbptr, int option)。 程序例 : include include include include int main(void) { char line[80]。 struct fcb blk。 /* get file name */ printf(Enter drive and file name (no path ie. a:)\n)。 gets(line)。 /* put file name in fcb */ if (parsfnm(line, amp。blk, 1) == NULL) printf(Error in parsfm call\n)。 else printf(Drive %d Name: %11s\n, , )。 return 0。 } 函數(shù)名 : peek 功 能 : 檢查存儲單元 用 法 : int peek(int segment, unsigned offset)。 程序例 : include include include int main(void) { int value = 0。 printf(The current status of your keyboard is:\n)。 value = peek(0x0040, 0x0017)。 if (value amp。 1) printf(Right shift on\n)。 else printf(Right shift off\n)。 if (value amp。 2) printf(Left shift on\n)。 else printf(Left shift off\n)。 if (value amp。 4) printf(Control key on\n)。 else printf(Control key off\n)。 if (value amp。 8) printf(Alt key on\n)。 else printf(Alt key off\n)。 if (value amp。 16) printf(Scroll lock on\n)。 else printf(Scroll lock off\n)。 if (value amp。 32) printf(Num lock on\n)。 else printf(Num lock off\n)。 if (value amp。 64) printf(Caps lock on\n)。 else printf(Caps lock off\n)。 return 0。 } 函數(shù)名 : peekb 功 能 : 檢查存儲單元 用 法 : char peekb (int segment, unsigned offset)。 程序例 : include include include int main(void) { int value = 0。 printf(The current status of your keyboard is:\n)。 value = peekb(0x0040, 0x0017)。 if (value amp。 1) printf(Right shift on\n)。 else printf(Right shift off\n)。 if (value amp。 2) printf(Left shift on\n)。 else printf(Left shift off\n)。 if (value amp。 4) printf(Control key on\n)。 else printf(Control key off\n)。 if (value amp。 8) printf(Alt key on\n)。 else printf(Alt key off\n)。 if (value amp。 16) printf(Scroll lock on\n)。 else printf(Scroll lock off\n)。 if (value amp。 32)