Код: Выделить всё
void waitOrEnter(double seconds) {
auto start = std::chrono::steady_clock::now();
while (true) {
// Check if the specified time has passed if the playthrough is equal to 0
if (playthrough == 0) {
auto now = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast(now - start).count();
if (elapsed >= seconds) {
cout = 1) {
if (_kbhit()) {
getch();
break;
}
// Sleep for a short amount of time
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
}
< /code>
И я называю его после каждой строки текста: < /p>
std::cout
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79588481/replacing-a-function-with-another-function-if-a-condition-is-met[/url]
Мобильная версия