#include <stdio.h>
int getchar(void);
#include <iostream>
#include <termios.h>
static struct termios stored_settings;
void set_keypress(void) {
struct termios new_settings;
tcgetattr(0,&stored_settings);
new_settings = stored_settings;
// Отключение канонического режима и эхо
new_settings.c_lflag &= ~(ICANON | ECHO);
new_settings.c_cc[VTIME] = 0;
new_settings.c_cc[VMIN] = 1;
tcsetattr(0,TCSANOW,&new_settings);
return;
} void reset_keypress(void) {
tcsetattr(0,TCSANOW,&stored_settings);
return;
}
int main() {
set_keypress();
char c;
std::cout << "Тут типа пауза...\n";
std::cin >> c;
std::cout << "Нажми че-то, чтобы выйти...\n";
std::cin >> c;
reset_keypress();
return 0;
}
Это? #include <chrono>
#include <iostream>
#include <thread>
namespace user {
void sleep(const intmax_t delay) {
const auto s = std::chrono::system_clock::now() + std::chrono::seconds(delay);
std::this_thread::sleep_until(s);
}
void clear() {
std::cout << "\x1B[2J\x1B[H";
// std::cout << "\033c"; // Linux
}
void pause(const char* prompt = "") {
std::cout << prompt;
while (std::cin.get() != '\n');
}
}
int main() {
constexpr auto delay = 5LL;
std::cout << "This is a " << delay << " second pause\n";
user::sleep(delay);
user::clear();
user::pause("Press any key... ");
std::cout << "Is this what you need?\n";
user::pause();
}