Hello. I'm trying to write a program witch asks you to write delay and then counts time left. But it's not working how it should. If i write number 9 or less it's working fine. But if i write number 10 or more it prints numbers wrong, ex. ir write 12, then program writes numbers like this: 12,11,10,90,80,70,60,50,40,30,20,10,00. Here's code:
#include <iostream>
#include <windows.h>
using namespace std;
int main () {
int delay;
cout << "Enter delay: ";
cin >> delay;
cout << "Time left: ";
for (delay; delay>=0; delay--) {
if (i >= 9)
cout << "\b";
cout << "\b" << i;
Sleep (1000);
if (i == 0) {
cout << endl << "Time over.\n";
}
}
cin.get();
return 0;
}
What am i doing wrong?
Sorry for my bad english. Hope you understood.