Clear the screen
Mi osobiście "przypadła do gustu": <curses.h> np.:
online
#include <curses.h>
int main()
{
char users_name[100];
// Remember, when using Curses, no change will appear
// on the screen until refresh() is called
initscr();
(void)echo();
addstr(" What is your name: ");
refresh();
getnstr(users_name, sizeof(users_name) - 1);
clear(); // system("cls");
printw(" Greetings and salutations %s!\n", users_name);
refresh();
printw("\n Press ENTER to quit.");
refresh();
getnstr(users_name, sizeof(users_name) - 1);
endwin();
return 0;
}
online
#include <iostream>
//#include <windows.h>
#include <curses.h>
#include <thread>
#include <chrono>
using namespace std;
int main()
{
int hrs=0, min=0, sec=0;
initscr();
while (true) {
//system("cls");
clear();
sec++;
if (sec == 60) {
sec = 0;
min++;
if (min == 60)
{
min = 0;
hrs++;
if (hrs == 24) hrs = 0;
}
}
printw("%02d:%02d:%02d", hrs, min, sec);
refresh();
//sleep(1);
this_thread::sleep_for (chrono::seconds(1));
if (hrs == 1) break; // po 1h koniec ;-)
}
endwin();
return 0;
}