📄 029.htm
字号:
<HTML><HEAD><meta http-equiv="Content-Type" content="text/html; charset=GB2312"><TITLE>王大刚-->C语言编程宝典-->K</TITLE>
<META NAME="keywords" CONTENT="王大刚 C语言编程宝典 K">
<META NAME="description" CONTENT="王大刚 - C语言编程宝典 - K">
<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="030.htm">后一页</A><BR>
<A HREF="028.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">K</FONT></B></center>
<hr color="#EE9B73" size="1" width="94%">
<P>函数名: kbhit
<BR>功 能: 检查当前按下的键
<BR>用 法: int kbhit(void);
<BR>程序例:
<BR>
<P>#include <conio.h>
<BR>
<P>int main(void)
<BR>{
<BR> cprintf("Press any key to continue:");
<BR> while (!kbhit()) /* do nothing */ ;
<BR> cprintf("\r\nA key was pressed...\r\n");
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<BR>
<P>函数名: keep
<BR>功 能: 退出并继续驻留
<BR>用 法: void keep(int status, int size);
<BR>程序例:
<BR>
<P>/***NOTE:
<BR> This is an interrupt service routine. You
<BR> can NOT compile this program with Test
<BR> Stack Overflow turned on and get an
<BR> executable file which will operate
<BR> correctly. Due to the nature of this
<BR> function the formula used to compute
<BR> the number of paragraphs may not
<BR> necessarily work in all cases. Use with
<BR> care! Terminate Stay Resident (TSR)
<BR> programs are complex and no other support
<BR> for them is provided. Refer to the
<BR> MS-DOS technical documentation
<BR> for more information. */
<BR>#include <dos.h>
<BR>/* The clock tick interrupt */
<BR>#define INTR 0x1C
<BR>/* Screen attribute (blue on grey) */
<BR>#define ATTR 0x7900
<BR>
<P>/* reduce heaplength and stacklength
<BR>to make a smaller program in memory */
<BR>extern unsigned _heaplen = 1024;
<BR>extern unsigned _stklen = 512;
<BR>
<P>void interrupt ( *oldhandler)(void);
<BR>
<P>void interrupt handler(void)
<BR>{
<BR> unsigned int (far *screen)[80];
<BR> static int count;
<BR>
<P>/* For a color screen the video memory
<BR> is at B800:0000. For a monochrome
<BR> system use B000:000 */
<BR> screen = MK_FP(0xB800,0);
<BR>
<P>/* increase the counter and keep it
<BR> within 0 to 9 */
<BR> count++;
<BR> count %= 10;
<BR>
<P>/* put the number on the screen */
<BR> screen[0][79] = count + '0' + ATTR;
<BR>
<P>/* call the old interrupt handler */
<BR> oldhandler();
<BR>}
<BR>
<P>int main(void)
<BR>{
<BR>
<P>/* get the address of the current clock
<BR> tick interrupt */
<BR>oldhandler = getvect(INTR);
<BR>
<P>/* install the new interrupt handler */
<BR>setvect(INTR, handler);
<BR>
<P>/* _psp is the starting address of the
<BR> program in memory. The top of the stack
<BR> is the end of the program. Using _SS and
<BR> _SP together we can get the end of the
<BR> stack. You may want to allow a bit of
<BR> saftey space to insure that enough room
<BR> is being allocated ie:
<BR> (_SS + ((_SP + safety space)/16) - _psp)
<BR>*/
<BR>keep(0, (_SS + (_SP/16) - _psp));
<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="030.htm">后一页</A><BR>
<A HREF="028.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 + -