Linux终端刷新显示

void CStat::runtimePrintBuf(std::vector<std::string> &buf){
    static int last_print_lines = 0;
    for(int i = 0; i < last_print_lines; ++i){
        printf("\033[1A"); //先回到上一行
        printf("\033[K");  //清除该行
    }
    last_print_lines = buf.size();

    for(const std::string &it : buf){
        printf("%s\n", it.c_str());
    }
}
posted @ 2020-08-27 17:18  delta1037  阅读(350)  评论(0编辑  收藏  举报