I'm aware that this type of function is OS-dependant, but I'm hoping to find the best way to implement this functionality (particularly on Windows, but if there's a universal solution I don't know, I'm open to suggestions).
I'm trying to detect a keypress without the user pressing enter at the end. For angband/rogue style controls.
#include <curses.h>
int main()
{
initscr(); // init curses
printw("Hello world!\nPress any key to continue...");
getch(); // that's what you need
endwin(); // end curses mode
}
curses just looks a little... extreme from glancing at the win32 code. It includes all of the windows libraries, creates various handles and instances... it just seems a little crazy when that _getche command is a single line and a single library.
I don't know anything about windows programming--I'm just a beginner myself, but you may be able to use getchar() from cstdio.h , assuming that a c standard library is cross-platform. http://www.cplusplus.com/reference/clibrary/cstdio/getchar/