Thanks anduril, that example certainly works, though curses seems to make the rest of my program behave quite strangely. As I mentioned this is a modification to a large, exisiting bit of code.
I have put your curses example at the begining of my main loop (after removing the 'return 0', of course). I was hoping that afer exiting the while loop and calling endwin(), the rest of my code could run as before, using 'printf' to display strings to the user. However, it seems that I can only do this now by calling refresh, and even then this doesn't always work if a time delay is involved in generating the string (when polling a sensor for example). Worst of all is that my program now hangs occasionally and doesn't respond to Ctrl+C.
So now I have two questions,
1. Is it possible to use curses.h and getch for a while loop, then 'switch it off', so that I can go back to using printf? endwin() doesn't seem to do this...
2. Is there another way to achieve the goal I want (of entering keystrokes while running a while loop) that doesn't mean changing the way I display data on the screen (refreshing doesn't seem to work with time delays). Perhaps something other than getch and curses.h.