#include <iostream>
#include <thread>
#include <chrono>
using namespace std;
int main()
{
std::cout << "1";
std::this_thread::sleep_for( std::chrono::milliseconds(1000) );
std::cout << "2";
std::this_thread::sleep_for( std::chrono::milliseconds(1000) );
std::cout << "3";
std::this_thread::sleep_for( std::chrono::milliseconds(1000) );
return 1;
}
I want std::cout
to be printed every second.
But when I run this code, the result value 123
is printed at the same time.
Why?
And please tell me how to fix it.
Aucun commentaire:
Enregistrer un commentaire