Пишится это просто. Редактируется строка и выводится в одну и ту же позицию. Самый элементарный пример
| Код | #include <iostream>
using namespace std; int main(int argc, char* argv[]) { string str("================================="); string symb("-\\|/"); unsigned short str_index = 0; unsigned short symb_index = 0; unsigned short counter = 0; while(1){
str.replace(str_index, 1, symb.substr(symb_index,1)); if(!str_index) str.replace(str.length() - 1, 1, string("=")); else str.replace(str_index - 1, 1, string("="));
if(counter == 200){ counter = 0; str_index++; } if(str_index == str.length()) str_index = 0;
symb_index = symb_index == symb.length() - 1? 0: symb_index + 1; cout << str.c_str() << "\r"; counter++; } return 0; }
|
|