In Linux, console applications often display their progress by the similarity of this: [####___] 50% , while the inscription is “updated” in the same place in the terminal, rather than spamming in cmd, as does the count <<"сообщение"<<endl; in Windows. I look at such "spam" now, it would be better to have one "updated" line. 
|
2 answers
Run the following code:
#include <string> #include <iostream> #include <chrono> #include <thread> using namespace std; int main(int argc, const char * argv[]) { for(int i = 0;; ++i) { string s; for(int j = 0; j < 50; ++j) { s.push_back(j < i%50 ? '#' : ' '); } s.push_back('\r'); cout << s; this_thread::sleep_for(50ms); } } Perhaps if you do not have VC ++, you will also need to reset the cout buffer.
|
#include<Windows.h> int main () { HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOut, {10,10}); //Эта функция устанавливает положение курсора, то есть можно перерисовать результат return 0; } |
\r, for example - Abyx