o.txt
Upload User: harvey99
Upload Date: 2020-01-11
Package Size: 938k
Code Size: 3k
Category:

Other Books

Development Platform:

CHM

  1.  返回>>C语言函数大全
  2. 函数名: open
  3. 功  能: 打开一个文件用于读或写
  4. 用  法: int open(char *pathname, int access[, int permiss]);
  5. 程序例: 
  6. #include <string.h>
  7. #include <stdio.h>
  8. #include <fcntl.h>
  9. #include <io.h>
  10. int main(void)
  11. {
  12.    int handle;
  13.    char msg[] = "Hello world";
  14.    if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
  15.    {
  16.       perror("Error:");
  17.       return 1;
  18.    }
  19.    write(handle, msg, strlen(msg));
  20.    close(handle);
  21.    return 0;
  22. }
  23.  
  24.  
  25. 函数名: outport
  26. 功  能: 输出整数到硬件端口中
  27. 用  法: void outport(int port, int value);
  28. 程序例:
  29. #include <stdio.h>
  30. #include <dos.h>
  31. int main(void)
  32. {
  33.    int value = 64;
  34.    int port = 0;
  35.    outportb(port, value);
  36.    printf("Value %d sent to port number %dn", value, port);
  37.    return 0;
  38. }
  39.  
  40.  
  41. 函数名: outportb
  42. 功  能: 输出字节到硬件端口中
  43. 用  法: void outportb(int port, char byte);
  44. 程序例:
  45. #include <stdio.h>
  46. #include <dos.h>
  47. int main(void)
  48. {
  49.    int value = 64;
  50.    int port = 0;
  51.    outportb(port, value);
  52.    printf("Value %d sent to port number %dn", value, port);
  53.    return 0;
  54. }
  55.  
  56.  
  57. 函数名: outtext
  58. 功  能: 在视区显示一个字符串
  59. 用  法: void far outtext(char far *textstring);
  60. 程序例:
  61. #include <graphics.h>
  62. #include <stdlib.h>
  63. #include <stdio.h>
  64. #include <conio.h>
  65. int main(void)
  66. {
  67.    /* request auto detection */
  68.    int gdriver = DETECT, gmode, errorcode;
  69.    int midx, midy;
  70.    /* initialize graphics and local variables */
  71.    initgraph(&gdriver, &gmode, "");
  72.    /* read result of initialization */
  73.    errorcode = graphresult();
  74.    if (errorcode != grOk)  /* an error occurred */
  75.    {
  76.       printf("Graphics error: %sn", grapherrormsg(errorcode));
  77.       printf("Press any key to halt:");
  78.       getch();
  79.       exit(1); /* terminate with an error code */
  80.    }
  81.    midx = getmaxx() / 2;
  82.    midy = getmaxy() / 2;
  83.    /* move the C.P. to the center of the screen */
  84.    moveto(midx, midy);
  85.    /* output text starting at the C.P. */
  86.    outtext("This ");
  87.    outtext("is ");
  88.    outtext("a ");
  89.    outtext("test.");
  90.    /* clean up */
  91.    getch();
  92.    closegraph();
  93.    return 0;
  94. }
  95.  
  96.  
  97. 函数名: outtextxy
  98. 功  能: 在指定位置显示一字符串
  99. 用  法: void far outtextxy(int x, int y, char *textstring);
  100. 程序例:
  101. #include <graphics.h>
  102. #include <stdlib.h>
  103. #include <stdio.h>
  104. #include <conio.h>
  105. int main(void)
  106. {
  107.    /* request auto detection */
  108.    int gdriver = DETECT, gmode, errorcode;
  109.    int midx, midy;
  110.    /* initialize graphics and local variables */
  111.    initgraph( &gdriver, &gmode, "");
  112.    /* read result of initialization */
  113.    errorcode = graphresult();
  114.    if (errorcode != grOk)  /* an error occurred */
  115.    {
  116.       printf("Graphics error: %sn", grapherrormsg(errorcode));
  117.       printf("Press any key to halt:");
  118.       getch();
  119.       exit(1); /* terminate with an error code */
  120.    }
  121.    midx = getmaxx() / 2;
  122.    midy = getmaxy() / 2;
  123.    /* output text at the center of the screen*/
  124.    /* Note: the C.P. doesn't get changed.*/
  125.    outtextxy(midx, midy, "This is a test.");
  126.    /* clean up */
  127.    getch();
  128.    closegraph();
  129.    return 0;
  130. }
  131.