0

so no code to go off, but how would you replace a line in a console application in cpp. so instead of making a new line, you replace the text without creating a new line. string toggle = "OFF";

printf("TOGGLE: %s", toggle);//an if statement changes toggle but never changes.

should i be looping?

example:

Toggle: ON //Instead of making a new line saying...
Toggle: OFF // how could i replace the Toggle: ON to say toggle off when i toggle off.
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190

1 Answers1

1

It depends on how you can control your terminal. There is a special character that might allow you to emulate a backspace (`\b') as you would have typed in the console. You can use that to control output within the same line.

In general for portable terminal control consider using ncurses or such.

Community
  • 1
  • 1
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190