I've got a small problem and I'm not sure if there's a possible way around this with iostream code, but I thought it's worth asking anyway.
#include <iostream>
#include <string>
using namespace std;
string cmd;
int main() {
cout << "-------------" << endl;
cout << "command: ";
cin >> cmd;
cout << "-------------" << endl;
system("pause");
}
Is it anyway possible to print the 3rd cout line before the user has typed into the cmd variable? That way, the text field will be wrapped with the "-" above and below, looking like this:
-------------
command: <user would type here>
-------------
If this is not possible, could you please point me into the direction of some possible libraries that I could use to achieve this?
There is no standard way of achieving this in C++.
Different terminals have their own capabilities and different systems have their own API's for interacting with the terminal.
The output of the bottom line must certainly be performed first before waiting for the input, but it may be possible to move the output "cursor" to some other location than the bottom of the screen. You may find details in the documentation of the system that you intend to target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With