知識社群登入
位置: AutoCAD開放式教學 > 討論區 > 討論
0208, skip(), pause()
1樓

//   skip(-3);
void skip(int no)
{
// limits no in 1 .. 20
if ((no >= 1) && (no <= 20)) {// no is OK
int i;
for (i=1;i<=no;i++) {
printf("\n");
}
}
else {// no is invalid!
printf("\n");
}
}// end of skip()
// ----------------------------------------------

//   pause();
void pause(void)
{
// remove type- ahead
while (kbhit()) {
getch();
}
// ----------------------------------------------
printf(" *** Press [Esc] key for Stop! or other key for Continue...");
do {
// wait for KeyPress
} while(!_kbhit());
int ch1= getch();
printf("\n");
// ----------------------------------------------
if (ch1==0x1b) {// [Esc] key be pressed
exit(1);
}
// remove extra key Strok
while (kbhit()) {
getch();
}
}// end of pause()
// ----------------------------------------------