📄 fo.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="Author" content="wdg">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>网上学堂 --> C语言编程宝典之一 -->函数名: o</title>
</head>
<body>
<div align="center"><center>
<table border="1" cellpadding="4" width="640"
bordercolordark="#FFFFFF" bordercolorlight="#FFFFFF">
<tr>
<td bgcolor="#FFE6B0" bordercolor="#8080FF" class="p9"><font
color="#BB0000">导航条:--></font> <a
href="../../index.html">网上学堂</a> --> <a
href="../tcindex.htm"><font face="宋体">C</font>语言编程宝典之一</a>
-->函数名: o</td>
</tr>
<tr>
<td bordercolor="#8080FF" class="p9">函数名: open <br>
功 能: 打开一个文件用于读或写 <br>
用 法: int open(char *pathname, int access[, int
permiss]); <br>
程序例: <p>#include <string.h> <br>
#include <stdio.h> <br>
#include <fcntl.h> <br>
#include <io.h> </p>
<p>int main(void) <br>
{ <br>
int handle; <br>
char msg[] = "Hello world"; </p>
<p> if ((handle = open("TEST.$$$",
O_CREAT | O_TEXT)) == -1) <br>
{ <br>
perror("Error:"); <br>
return 1; <br>
} <br>
write(handle, msg, strlen(msg)); <br>
close(handle); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: outport <br>
功 能: 输出整数到硬件端口中 <br>
用 法: void outport(int port, int value); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
int value = 64; <br>
int port = 0; </p>
<p> outportb(port, value); <br>
printf("Value %d sent to port number
%d\n", value, port); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: outportb <br>
功 能: 输出字节到硬件端口中 <br>
用 法: void outportb(int port, char byte); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
int value = 64; <br>
int port = 0; </p>
<p> outportb(port, value); <br>
printf("Value %d sent to port number
%d\n", value, port); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: outtext <br>
功 能: 在视区显示一个字符串 <br>
用 法: void far outtext(char far *textstring); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error
occurred */ <br>
{ <br>
printf("Graphics
error: %s\n", grapherrormsg(errorcode)); <br>
printf("Press any key
to halt:"); <br>
getch(); <br>
exit(1); /* terminate with
an error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p> /* move the C.P. to the center of the
screen */ <br>
moveto(midx, midy); </p>
<p> /* output text starting at the C.P. */ <br>
outtext("This "); <br>
outtext("is "); <br>
outtext("a "); <br>
outtext("test."); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: outtextxy <br>
功 能: 在指定位置显示一字符串 <br>
用 法: void far outtextxy(int x, int y, char
*textstring); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph( &gdriver, &gmode,
""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error
occurred */ <br>
{ <br>
printf("Graphics
error: %s\n", grapherrormsg(errorcode)); <br>
printf("Press any key
to halt:"); <br>
getch(); <br>
exit(1); /* terminate with
an error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p> /* output text at the center of the
screen*/ <br>
/* Note: the C.P. doesn't get changed.*/ <br>
outtextxy(midx, midy, "This is a
test."); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
</p>
</td>
</tr>
</table>
</center></div><div align="center"><center>
<table border="0" cellspacing="1" width="640">
<tr>
<td class="p9" height="60"> <script>document.write("<p><a href=\"http://view.gznet.com/cgi-bin/rl_views.cgi?UID=10013421\" target=sxrl>");
document.write("<img src=\"http://refer.gznet.com/cgi-bin/rl_refer2.cgi?UID=10013421&refer="+escape(top.document.referrer)+"\" width=1 height=1 border=0 alt=\" \">");
document.write("</a>");
</script></td>
</tr>
</table>
</center></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -