You can use ANSI codes in c++, too:
#include <iostream>
using namespace std;
extern "C" {
#include <unistd.h>
}
int main() {
int n = 0;
cout << " %";
while (n < 10) {
// move cursor to first column, print number, move cursor to fifth column
cout << "\033[1G" << n*10 << "\033[5G" << flush;
sleep(1);
n++;
}
// print in red
cout << "\nTest color: \033[1;31mred\033[0m" << endl;
}
#include <iostream>
using namespace std;
extern "C" {
#include <unistd.h>
}
int main() {
int n = 0;
cout << " %";
while (n < 10) {
// move cursor to first column, print number, move cursor to fifth column
cout << "\033[1G" << n*10 << "\033[5G" << flush;
sleep(1);
n++;
}
// print in red
cout << "\nTest color: \033[1;31mred\033[0m" << endl;
}
To copy to clipboard, switch view to plain text mode
Bookmarks