C's pause()
(高顯忠, sjgau4311@gmail.com, 2012-03-21 07:41)
1樓
#include <stdio.h>
#include <stdlib.h>
#include "skip-01.h"
// ----------------------------------------------
// pause();
void pause(void)
{
int ch1;
// remove type ahead
while (kbhit()) {
ch1= getch();
}
// -------------------------------------------
skip(1);
printf("Press [Esc] for stop! other key for continue... ");
do {
// wait for keyPressed
} while (!kbhit());
ch1= getch();
// -------------------------------------------
if (ch1 == 0x1b) {// [Esc] key be pressed
exit(1);
}
// remove extra keyPressed
while (kbhit()) {
ch1= getch();
}
}// end of pause()
// ----------------------------------------------
int main(int argc, char *argv[])
{
int i;
skip(-3);
system("PAUSE");
skip(33);
system("PAUSE");
for (i=1;i<=20;i++) {
skip(i);
printf("i= %5d, i*i= %5d, sqrt(i)= %13.9lf \n",
i, i*i, sqrt(i));
// system("PAUSE");
pause();
}
system("PAUSE");
return 0;
}// end of main()