There isn't anything standard that would do that, so you lose any chance of code portability.
What compiler and OS are you using.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Like iamthwee indicated, there is no standard way to do that. You'll have to do something OS-specific.
I suggest you check out the Curses library.
POSIX: NCurses
Win32: PDCurses
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
You may already have NCurses installed.
Try the following program to see if you do.
// hello.cpp
#include <curses.h>
int main() {
initscr();
raw();
noecho();
nonl();
intrflush( stdscr, FALSE );
keypad( stdscr, TRUE );
mvaddstr( 10, 10, "Hello, world" );
mvaddstr( 11, 10, "Press the 'any' key." );
wgetch( stdscr );
endwin();
return 0;
}
Compile with g++ -o hello hello.cpp -lncurses .
The code is valid C code also, so it doesn't matter if you usegcc or g++.
If it complains that it doesn't know what libncurses is, try -lcurses, and if that fails, use
sudo apt-get install ncurses-dev
and that should (hopefully) get you everything you need.
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439