0

i want help to get delay between the numbers in the countdown for like 0.75 seconds for each line, i tried adding Sleep function and it says it cannot define identifier

#include<iostream>
#include<dos.h>
using namespace std;
int main()

{

float a;
cout << "Lets do a countdown, write a number:" << endl;
cin >> (a);
while (a > 0) {

    cout << a << endl;
    a = a--;
}
cout << "Countdown Aborted" << endl;
system("pause");

}
  • 3
    `a--` already decrements `a`. Assigning the result to `a` on top of that changes it from working to not working. – chris Oct 11 '17 at 16:11
  • So, i found out that i should be using `` and not ``. Thank you anyways – TheZedYasuo Oct 11 '17 at 16:19
  • You probably should not even be using that. Nothing in your code example needs `windows.h` `system` needs `#include ` – drescherjm Oct 11 '17 at 16:27
  • 2
    `#include ` then.. `std::this_thread::sleep_for(std::chrono:: milliseconds(75));` assuming C++11. – Brandon Oct 11 '17 at 16:35
  • on the dupe please pay attention to the answer giving a C++11 solution. It is the preferred way. – bolov Oct 11 '17 at 16:44

0 Answers0