getch() and variants are not cross-platform.
Your best bet is to use the
curses library. There are three variants: curses (the oldest and most basic), ncurses (a big improvement), and pdcurses (ditto). Most (if not all) Unix/Linux platforms have at least curses, if not ncurses. PDCurses, in addition to Unix variants, comes available on DOS, OS/2, Windows, Plan 9, and the Amiga.
That covers many desktop systems people will be using (including OS X), but nowhere near all.
Here's an example in another post of mine --doing exactly what you want.
Keep in mind, like
WaltP said, there is no truly cross-platform method. Also, once you start using curses you cannot use the standard C/C++ I/O --it is one or the other.
Hope this helps.