I started learning programming a few days ago, and today i tried writing a countdown program, but everytime i try to start a program i get error: 'sleep' was not declared in this scope. I searched everywhere for solution but i didn't find it.
#include <iostream>
#include <windows.h>
#include <cstdlib>
using namespace std;
int main()
{
for(int i=30; i>=0; i--)
{
sleep(1000)
system("cls")
cout << i;
}
return 0;
}
Try this out:
this_thread::sleep_for(2s);
Source: https://en.cppreference.com/w/cpp/thread/sleep_for
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With