Help with selection

Hello guys,

I tried to make a kind of a menu but I don't know how to make the selection

I have alot on options to use I know but I wanna do like a toggle selection
like [on] and [off] and in the text display anyone know how to I make the user change it
example:

1
2
3
4
5
6
7
#include <iostream>
using namespace std;

int main() { 

cout << "Engine[off]" << endl; // How to I make it changeable

I wanna do like up down selection with the arrows and when I select it with the "Enter" key its changes

thanks for the helpers :)









You do print one constant string literal "Engine[off]". That cannot change.

You have to store data in variable(s) and print something based on the data:
1
2
3
4
5
#include <iostream>
int main() { 
  bool foo = true;
  std::cout << "Engine[" << (foo ? "on" : "off") << "]\n";
}


I wanna do like up down selection with the arrows and when I select it with the "Enter" key its changes

C++ language and C++ Standard Library has nothing for that.

Third-party libraries, like Ncurses https://en.wikipedia.org/wiki/Ncurses
support what you want.
@keskiverto,

Since you mentioned it. Is nurrses for POSIX or does it work with windows. Bear with me I am still trying to understand POSIX.

Andy
closed account (E0p9LyTq)
Ncurses for Windows (as well as other OSes), PDCurses:

https://pdcurses.sourceforge.io/
Last edited on
@FurryGuy,

Thanks.

Andy
Last edited on
closed account (E0p9LyTq)
I don't use Curses, NCurses or PDCurses, so I can't say how good the libraries are.

Personally, if I am going to manipulate text I won't bother with a console and create a GUI.
Thanks @kkeskiverto, @FurryGuy, @Handy Andy,
Topic archived. No new replies allowed.