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. // ----------------------------------------------   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值