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

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

📁 初学者的良师益友。其中包括C的全部教程。
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0038)http://www.hjflying.8u8.com/cl/029.htm -->
<HTML><HEAD><TITLE>王大刚-->C语言编程宝典-->K</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GB2312">
<META content="王大刚 C语言编程宝典 K" name=keywords>
<META content="王大刚 - C语言编程宝典 - K" 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/030.htm">后一页</A><BR><A 
      href="http://www.hjflying.8u8.com/cl/028.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>K</FONT></B></CENTER>
      <HR width="94%" color=#ee9b73 SIZE=1>

      <P>函数名: kbhit <BR>功&nbsp; 能: 检查当前按下的键 <BR>用&nbsp; 法: int kbhit(void); 
      <BR>程序例: <BR>
      <P>#include &lt;conio.h&gt; <BR>
      <P>int main(void) <BR>{ <BR>&nbsp;&nbsp; cprintf("Press any key to 
      continue:"); <BR>&nbsp;&nbsp; while (!kbhit()) /* do nothing */ ; 
      <BR>&nbsp;&nbsp; cprintf("\r\nA key was pressed...\r\n"); <BR>&nbsp;&nbsp; 
      return 0; <BR>} <BR>&nbsp; <BR>&nbsp; <BR>&nbsp; <BR>
      <P>函数名: keep <BR>功&nbsp; 能: 退出并继续驻留 <BR>用&nbsp; 法: void keep(int status, 
      int size); <BR>程序例: <BR>
      <P>/***NOTE: <BR>&nbsp;&nbsp; This is an interrupt service routine.&nbsp; 
      You <BR>&nbsp;&nbsp; can NOT compile this program with Test 
      <BR>&nbsp;&nbsp; Stack Overflow turned on and get an <BR>&nbsp;&nbsp; 
      executable file which will operate <BR>&nbsp;&nbsp; correctly.&nbsp; Due 
      to the nature of this <BR>&nbsp;&nbsp; function the formula used to 
      compute <BR>&nbsp;&nbsp; the number of paragraphs may not <BR>&nbsp;&nbsp; 
      necessarily work in all cases.&nbsp; Use with <BR>&nbsp;&nbsp; care!&nbsp; 
      Terminate Stay Resident (TSR) <BR>&nbsp;&nbsp; programs are complex and no 
      other support <BR>&nbsp;&nbsp; for them is provided.&nbsp; Refer to the 
      <BR>&nbsp;&nbsp; MS-DOS technical documentation <BR>&nbsp;&nbsp; for more 
      information.&nbsp; */ <BR>#include &lt;dos.h&gt; <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&nbsp; = 512; <BR>
      <P>void interrupt ( *oldhandler)(void); <BR>
      <P>void interrupt handler(void) <BR>{ <BR>&nbsp;&nbsp; unsigned int (far 
      *screen)[80]; <BR>&nbsp;&nbsp; static int count; <BR>
      <P>/* For a color screen the video memory <BR>&nbsp;&nbsp; is at 
      B800:0000.&nbsp; For a monochrome <BR>&nbsp;&nbsp; system use B000:000 */ 
      <BR>&nbsp;&nbsp; screen = MK_FP(0xB800,0); <BR>
      <P>/* increase the counter and keep it <BR>&nbsp;&nbsp; within 0 to 9 */ 
      <BR>&nbsp;&nbsp; count++; <BR>&nbsp;&nbsp; count %= 10; <BR>
      <P>/* put the number on the screen */ <BR>&nbsp;&nbsp; screen[0][79] = 
      count + '0' + ATTR; <BR>
      <P>/* call the old interrupt handler */ <BR>&nbsp;&nbsp; oldhandler(); 
      <BR>} <BR>
      <P>int main(void) <BR>{ <BR>
      <P>/* get the address of the current clock <BR>&nbsp;&nbsp; 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>&nbsp;&nbsp; program in 
      memory.&nbsp; The top of the stack <BR>&nbsp;&nbsp; is the end of the 
      program.&nbsp; Using _SS and <BR>&nbsp;&nbsp; _SP together we can get the 
      end of the <BR>&nbsp;&nbsp; stack.&nbsp; You may want to allow a bit of 
      <BR>&nbsp;&nbsp; saftey space to insure that enough room <BR>&nbsp;&nbsp; 
      is being allocated ie: <BR>&nbsp;&nbsp; (_SS + ((_SP + safety space)/16) - 
      _psp) <BR>*/ <BR>keep(0, (_SS + (_SP/16) - _psp)); <BR>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/030.htm">后一页</A><BR><A 
      href="http://www.hjflying.8u8.com/cl/028.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 + -