📄 040.htm
字号:
<HTML><HEAD><meta http-equiv="Content-Type" content="text/html; charset=GB2312"><TITLE>王大刚-->C语言编程宝典-->W</TITLE>
<META NAME="keywords" CONTENT="王大刚 C语言编程宝典 W">
<META NAME="description" CONTENT="王大刚 - C语言编程宝典 - W">
<style>
<!--
#page {position:absolute; z-index:0; left:0px; top:0px}
.tt3 {font: 9pt/12pt "宋体"}
.tt2 {font: 12pt/15pt "宋体"}
a {text-decoration:none}
a:hover {color: blue;text-decoration:underline}
-->
</style>
</HEAD>
<body text="#000000" aLink=#9900ff link=#006699 vLink=#006699 bgcolor="#FFFFFF" leftmargin="3" topmargin="3" marginheight="3" marginwidth="3">
<TABLE WIDTH="100%" CELLPADDING=10 CELLSPACING=0 BORDER=0>
<TR>
<TD CLASS="tt3" VALIGN="top" width="8%" bgcolor="#e0e0e0"><strong><A HREF="041.htm">后一页</A><BR>
<A HREF="039.htm">前一页</A><BR>
<A HREF="index.html">回目录</A><BR>
<A HREF="../../../../index.htm">回首页</A><BR>
</strong>
</TD>
<TD class="tt2" bgcolor="#F5F8F8" width="84%"><center><B><FONT style="FONT-SIZE: 16.5pt" COLOR="#FF6666" FACE="楷体_GB2312">W</FONT></B></center>
<hr color="#EE9B73" size="1" width="94%">
<P>函数名: wherex
<BR>功 能: 返回窗口内水平光标位置
<BR>用 法: int wherex(void);
<BR>程序例:
<BR>
<P>#include <conio.h>
<BR>
<P>int main(void)
<BR>{
<BR> clrscr();
<BR> gotoxy(10,10);
<BR> cprintf("Current location is X: %d Y: %d\r\n", wherex(),
wherey());
<BR> getch();
<BR>
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<BR>
<P>函数名: wherey
<BR>功 能: 返回窗口内垂直光标位置
<BR>用 法: int wherey(void);
<BR>程序例:
<BR>
<P>#include <conio.h>
<BR>
<P>int main(void)
<BR>{
<BR> clrscr();
<BR> gotoxy(10,10);
<BR> cprintf("Current location is X: %d Y: %d\r\n", wherex(),
wherey());
<BR> getch();
<BR>
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<BR>
<P>函数名: window
<BR>功 能: 定义活动文本模式窗口
<BR>用 法: void window(int left, int top, int right, int bottom);
<BR>程序例:
<BR>
<P>#include <conio.h>
<BR>
<P>int main(void)
<BR>{
<BR>
<P> window(10,10,40,11);
<BR> textcolor(BLACK);
<BR> textbackground(WHITE);
<BR> cprintf("This is a test\r\n");
<BR>
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<BR>
<P>函数名: write
<BR>功 能: 写到一文件中
<BR>用 法: int write(int handel, void *buf, int nbyte);
<BR>程序例:
<BR>
<P>#include <stdio.h>
<BR>#include <stdlib.h>
<BR>#include <fcntl.h>
<BR>#include <sys\stat.h>
<BR>#include <io.h>
<BR>#include <string.h>
<BR>
<P>int main(void)
<BR>{
<BR> int handle;
<BR> char string[40];
<BR> int length, res;
<BR>
<P> /*
<BR> Create a file named "TEST.$$$" in the current directory
and write
<BR> a string to it. If "TEST.$$$" already exists,
it will be overwritten.
<BR> */
<BR>
<P> if ((handle = open("TEST.$$$", O_WRONLY | O_CREAT | O_TRUNC,
<BR>
S_IREAD | S_IWRITE)) == -1)
<BR> {
<BR> printf("Error opening file.\n");
<BR> exit(1);
<BR> }
<BR>
<P> strcpy(string, "Hello, world!\n");
<BR> length = strlen(string);
<BR>
<P> if ((res = write(handle, string, length)) != length)
<BR> {
<BR> printf("Error writing to the file.\n");
<BR> exit(1);
<BR> }
<BR> printf("Wrote %d bytes to the file.\n", res);
<BR>
<P> close(handle);
<BR> return 0;
<BR>}
<BR>
<BR>
<hr color="#EE9B73" size="1" width="94%">
</TD>
<TD CLASS="tt3" VALIGN="bottom" width="8%" bgcolor="#e0e0e0"><strong><A HREF="041.htm">后一页</A><BR>
<A HREF="039.htm">前一页</A><BR>
<A HREF="index.html">回目录</A><BR>
<A HREF="../../../../index.htm">回首页</A><BR>
</strong>
</TD>
</TR>
</table>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -