To give a very hacked (but understandable) example, and borrowing from Oluseyi''s code:
// some state variable declaredbool typing = false;// main game loopwhile(not_done){ // other stuff... //*** input section ***/ if(kbhit()) { if (typing) FillString(); // typing handler else { // find out which key was hit switch(getch()) { case ''`'': typing = true; break; case ''s'': // upper or lower case; use fall-through case ''S'': save_game(); break; // other case labels... } } } // other stuff...}
The typing handler would systematically get keyboard inputs and begin filling an input buffer, and would fire off some "string entered" event once the user hit enter (or whatever you find appropriate). You could also allow the user to cancel his typing request by hitting some other key, which would erase the buffer and not send a string out. Once either occurs, typing would be set to false once again.
"Don''t be afraid to dream, for out of such fragile things come miracles."