萬惡的c/c++——控制檯輸出 改寫當前行

if we just call the c/c++ standare output interface, such as printf, in fact we ouput new text at the back of already printed text, but sometimes, we have to modify the printed text in current line. in this case, we can use the format simbol such as '\b' and '\r'

'\b' will move the cursor back to one backspace, and '\r' will move the cursor to the beginning position of current line. one example is this:


printf("123");
printf("\b");
printf("abc");

the final output would be 12abc, and:

printf("123");
printf("\r");
printf("abc");

the final ouput would be abc, that 's all.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章