-
Quick O/I Question
is it possible to ask a question, but display the cursor above said question?
for example:
Code:
cout << "5 / 25 = ";
cin >> answer;
in the code snippet above, the cursor will appear one space after the = sign, but i want it to appear above the 5 / 25, is this possible?
-and if so, how?
-
Re: Quick O/I Question
I would say that's not possible in a shell. The shell will always print output and then return below for the next instruction. I don't see any way to achieve that behavior without writing your own interface.
Is there some urgent need to have the prompt appear above the text, or is this just aesthetic? Maybe you could tweak the shell to print from the bottom of the page up, or something like that.
LMHmedchem
-
Re: Quick O/I Question
From a strict C/C++ point of view, there is no shell, or terminal, or anything. There is just an "input stream" and an "output stream" (and log/err).
On windows/unix PCs, these streams are usually associated to a console, but that is the OS's choice.
To do what you want, you'll need an external library that can interface with your OS/console.
windows.h is a good place to start if you are on windows. I've heard conio is also good for simple command formating.
If your objective is to learn C++, then I wouldn't bother though. Output formatting is one of the less interesting, aspects of C++, and will bring you very little knowledge on the language.
-
Re: Quick O/I Question
If this is for Windows, <conio.h> won't help; it doesn't provide this capability. But the Windows Console API, in particular SetConsoleCursorPostion(), does. However this is even less C++-ish than <conio.h> because it's Windows API instead of C runtime library functions.
-
Re: Quick O/I Question
alright then, thanks guys, just wondering if there was a quick command or something, but if i need to mess with a interface, then i dont need it that much...