I am not sure if being in linux makes any different, but i have found online that this:
cout << \"Press Enter to Continue...\";
cin.ignore(nume
Here is a snippet from my code. It works in both windows and linux.
#include
using std::cout;
using std::cin;
// Clear and pause methods
#ifdef _WIN32
// For windows
void clearConsole() {
system("cls");
}
void waitForAnyKey() {
system("pause");
}
#elif __linux__
// For linux
void clearConsole() {
system("clear");
}
void waitForAnyKey() {
cout << "Press any key to continue...";
system("read -s -N 1"); // Continues when pressed a key like windows
}
#endif
int main() {
cout << "Hello World!\n";
waitForAnyKey();
clearConsole();
return 0;
}