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

📄 王大刚--c语言编程宝典--o.htm

📁 初学者的良师益友。其中包括C的全部教程。
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0038)http://www.hjflying.8u8.com/cl/032.htm -->
<HTML><HEAD><TITLE>王大刚-->C语言编程宝典-->O</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GB2312">
<META content="王大刚 C语言编程宝典 O" name=keywords>
<META content="王大刚 - C语言编程宝典 - O" name=description>
<STYLE>#page {
	LEFT: 0px; POSITION: absolute; TOP: 0px
}
.tt3 {
	FONT: 9pt/12pt "宋体"
}
.tt2 {
	FONT: 12pt/15pt "宋体"
}
A {
	TEXT-DECORATION: none
}
A:hover {
	COLOR: blue; TEXT-DECORATION: underline
}
</STYLE>

<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY text=#000000 vLink=#006699 aLink=#9900ff link=#006699 bgColor=#ffffff 
leftMargin=3 topMargin=3 marginwidth="3" marginheight="3">
<TABLE cellSpacing=0 cellPadding=10 width="100%" border=0>
  <TBODY>
  <TR>
    <TD class=tt3 vAlign=top width="8%" bgColor=#e0e0e0><STRONG><A 
      href="http://www.hjflying.8u8.com/cl/033.htm">后一页</A><BR><A 
      href="http://www.hjflying.8u8.com/cl/031.htm">前一页</A><BR><A 
      href="http://www.hjflying.8u8.com/cl/index.html">回目录</A><BR><A 
      href="http://www.hjflying.8u8.com/index.htm">回首页</A><BR></STRONG></TD>
    <TD class=tt2 width="84%" bgColor=#f5f8f8>
      <CENTER><B><FONT style="FONT-SIZE: 16.5pt" face=楷体_GB2312 
      color=#ff6666>O</FONT></B></CENTER>
      <HR width="94%" color=#ee9b73 SIZE=1>

      <P>函数名: open <BR>功&nbsp; 能: 打开一个文件用于读或写 <BR>用&nbsp; 法: int open(char 
      *pathname, int access[, int permiss]); <BR>程序例: <BR>
      <P>#include &lt;string.h&gt; <BR>#include &lt;stdio.h&gt; <BR>#include 
      &lt;fcntl.h&gt; <BR>#include &lt;io.h&gt; <BR>
      <P>int main(void) <BR>{ <BR>&nbsp;&nbsp; int handle; <BR>&nbsp;&nbsp; char 
      msg[] = "Hello world"; <BR>
      <P>&nbsp;&nbsp; if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) 
      <BR>&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; perror("Error:"); 
      <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1; <BR>&nbsp;&nbsp; } 
      <BR>&nbsp;&nbsp; write(handle, msg, strlen(msg)); <BR>&nbsp;&nbsp; 
      close(handle); <BR>&nbsp;&nbsp; return 0; <BR>} <BR>&nbsp; <BR>&nbsp; <BR>
      <P>函数名: outport <BR>功&nbsp; 能: 输出整数到硬件端口中 <BR>用&nbsp; 法: void outport(int 
      port, int value); <BR>程序例: <BR>
      <P>#include &lt;stdio.h&gt; <BR>#include &lt;dos.h&gt; <BR>
      <P>int main(void) <BR>{ <BR>&nbsp;&nbsp; int value = 64; <BR>&nbsp;&nbsp; 
      int port = 0; <BR>
      <P>&nbsp;&nbsp; outportb(port, value); <BR>&nbsp;&nbsp; printf("Value %d 
      sent to port number %d\n", value, port); <BR>&nbsp;&nbsp; return 0; <BR>} 
      <BR>&nbsp; <BR>&nbsp; <BR>
      <P>函数名: outportb <BR>功&nbsp; 能: 输出字节到硬件端口中 <BR>用&nbsp; 法: void 
      outportb(int port, char byte); <BR>程序例: <BR>
      <P>#include &lt;stdio.h&gt; <BR>#include &lt;dos.h&gt; <BR>
      <P>int main(void) <BR>{ <BR>&nbsp;&nbsp; int value = 64; <BR>&nbsp;&nbsp; 
      int port = 0; <BR>
      <P>&nbsp;&nbsp; outportb(port, value); <BR>&nbsp;&nbsp; printf("Value %d 
      sent to port number %d\n", value, port); <BR>&nbsp;&nbsp; return 0; <BR>} 
      <BR>&nbsp; <BR>&nbsp; <BR>
      <P>函数名: outtext <BR>功&nbsp; 能: 在视区显示一个字符串 <BR>用&nbsp; 法: void far 
      outtext(char far *textstring); <BR>程序例: <BR>
      <P>#include &lt;graphics.h&gt; <BR>#include &lt;stdlib.h&gt; <BR>#include 
      &lt;stdio.h&gt; <BR>#include &lt;conio.h&gt; <BR>
      <P>int main(void) <BR>{ <BR>&nbsp;&nbsp; /* request auto detection */ 
      <BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode; <BR>&nbsp;&nbsp; 
      int midx, midy; <BR>
      <P>&nbsp;&nbsp; /* initialize graphics and local variables */ 
      <BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, ""); <BR>
      <P>&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; } <BR>
      <P>&nbsp;&nbsp; midx = getmaxx() / 2; <BR>&nbsp;&nbsp; midy = getmaxy() / 
      2; <BR>
      <P>&nbsp;&nbsp; /* move the C.P. to the center of the screen */ 
      <BR>&nbsp;&nbsp; moveto(midx, midy); <BR>
      <P>&nbsp;&nbsp; /* output text starting at the C.P. */ <BR>&nbsp;&nbsp; 
      outtext("This "); <BR>&nbsp;&nbsp; outtext("is "); <BR>&nbsp;&nbsp; 
      outtext("a "); <BR>&nbsp;&nbsp; outtext("test."); <BR>
      <P>&nbsp;&nbsp; /* clean up */ <BR>&nbsp;&nbsp; getch(); <BR>&nbsp;&nbsp; 
      closegraph(); <BR>&nbsp;&nbsp; return 0; <BR>} <BR>&nbsp; <BR>&nbsp; <BR>
      <P>函数名: outtextxy <BR>功&nbsp; 能: 在指定位置显示一字符串 <BR>用&nbsp; 法: void far 
      outtextxy(int x, int y, char *textstring); <BR>程序例: <BR>
      <P>#include &lt;graphics.h&gt; <BR>#include &lt;stdlib.h&gt; <BR>#include 
      &lt;stdio.h&gt; <BR>#include &lt;conio.h&gt; <BR>
      <P>int main(void) <BR>{ <BR>&nbsp;&nbsp; /* request auto detection */ 
      <BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode; <BR>&nbsp;&nbsp; 
      int midx, midy; <BR>
      <P>&nbsp;&nbsp; /* initialize graphics and local variables */ 
      <BR>&nbsp;&nbsp; initgraph( &amp;gdriver, &amp;gmode, ""); <BR>
      <P>&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; } <BR>
      <P>&nbsp;&nbsp; midx = getmaxx() / 2; <BR>&nbsp;&nbsp; midy = getmaxy() / 
      2; <BR>
      <P>&nbsp;&nbsp; /* output text at the center of the screen*/ 
      <BR>&nbsp;&nbsp; /* Note: the C.P. doesn't get changed.*/ <BR>&nbsp;&nbsp; 
      outtextxy(midx, midy, "This is a test."); <BR>
      <P>&nbsp;&nbsp; /* clean up */ <BR>&nbsp;&nbsp; getch(); <BR>&nbsp;&nbsp; 
      closegraph(); <BR>&nbsp;&nbsp; return 0; <BR>} <BR>&nbsp; <BR>
      <HR width="94%" color=#ee9b73 SIZE=1>
    </TD>
    <TD class=tt3 vAlign=bottom width="8%" bgColor=#e0e0e0><STRONG><A 
      href="http://www.hjflying.8u8.com/cl/033.htm">后一页</A><BR><A 
      href="http://www.hjflying.8u8.com/cl/031.htm">前一页</A><BR><A 
      href="http://www.hjflying.8u8.com/cl/index.html">回目录</A><BR><A 
      href="http://www.hjflying.8u8.com/index.htm">回首页</A><BR></STRONG></TD></TR></TBODY></TABLE></BODY></HTML>

⌨️ 快捷键说明

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