Dec 10, 2012 at 11:29am UTC
I want to use cin so that when the input is expected from the keyboard there is existing text which can be edited and then press enter to read that data.
Is there a standard c++ way of doing this?
Thanks!
Dec 10, 2012 at 2:33pm UTC
The console output cannot be edited in a standard way. You could use the '\b' escape sequence to overwrite any existing characters. If you had:
"Enter your input"
then cout << "\b\b\b\b\b "; would make the output look like this:
"Enter your "
You can use getch() or GetAsyncKeyState or other ugly non-standard function to output "\b " each time backspace is pressed.
Dec 10, 2012 at 5:14pm UTC
What would be the best way in Linux?