`
sjgau
  • 浏览: 96558 次
  • 性别: Icon_minigender_1
  • 来自: 台灣省 台北市
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

C的 skip(no), pause()

阅读更多
cpp 代码
  1. // file: sj01.h   
  2.   
  3. void skip(int no);   
  4. void pause(void);   
  5. // ----------------------------------------------   
  6.   
  7. void skip(int no)   
  8. {   
  9.     // limits no in 1 .. 20   
  10.     if (!((no >= 1) && (no <= 20))) {   
  11.         printf("no is invalid! no= %d\n", no);   
  12.         pause();   
  13.   
  14.         no= 1;   
  15.     }   
  16.     // ----------------------------------------------   
  17.   
  18.     for (int i=1;i<=no;i++) {   
  19.         printf("\n");   
  20.     }   
  21. }// end skip()   
  22. // ----------------------------------------------   
  23.     
  24. void pause(void)   
  25. {   
  26.     // remove type- ahead   
  27.     while (_kbhit()) {   
  28.         _getch();   
  29.     }   
  30.     // ----------------------------------------------   
  31.   
  32.     printf(" Press [Esc] for stop! other key for continue...");   
  33.     do {   
  34.         // wait for keyPressed   
  35.     } while (!_kbhit());   
  36.        
  37.     int ch1= _getch();   
  38.     printf("\n");   
  39.     // ----------------------------------------------   
  40.   
  41.     if (ch1==0x1b) {   
  42.         exit(1);   
  43.     }   
  44.   
  45.     // remove other key   
  46.     while (_kbhit()) {   
  47.         _getch();   
  48.     }   
  49. }// end pause()   
  50. // ----------------------------------------------   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics