Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Change Output From "cout"

Is it possible to change text printed with "cout"? I would like to make it show the current percentage of something without having to have a new line for each percentage. Is this possible?

like image 262
nebkat Avatar asked Dec 08 '10 14:12

nebkat


1 Answers

This works for me:

std::cout << "1111";
std::cout << "\r";
std::cout << "2222";

\r is a carriage return symbol. Puts the "cursor" back to the beginning of the line.

Alternatively you can use \b character. This is backspace. When printed it goes one character back.

like image 165
detunized Avatar answered Oct 06 '22 13:10

detunized