[Solved] Creating a clock program


You are calling kbhit() twice, only once is needed per loop. It does not return a char.
You are calling getch() twice, you only need to once per loop.
You should improve what flag means. Maybe change to StoppedFlag.

 while (1) {
  if (kbhit()) {
    char ch = getch();
    if ((ch == 'S') || (ch == 's')) {
      flag = 0;
    }
    else if ((ch == 'E') || (ch == 'e')) {
      flag = 1;
    }
  }
  else {
    if(t <= 0) {
      break;
    }
    if (flag == 0) {
      t=t-1;
      Sleep(1000);
      printf("%ld ", t);
    }
  }
}

0

solved Creating a clock program