#Moving the cursor to erase text

9 messages · Page 1 of 1 (latest)

reef compass
#

Is there a better way of doing this?

std::cout << "\x1b[A";
for (int i = 0; i < (str.length() + num); i++) {std::cout << " ";}
std::cout << "\r";```
tender viperBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

reef compass
#

I'm used to Python and my brain keeps telling me to do this xD

print("\033[A", " " * (len(string) + num), end="\r")
plucky spade
#

i don't think there's a good cross-platform way (in fact this code might not work on all platforms)

reef compass
#

Oh no

#

Oh well, works for most Linux terminals

#

I'd still want to know if I can generate a string of spaces instead of using a for loop

#

Oh... this might work

std::cout << std::string( 5, ' ' ) << std::endl;
tender viperBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.