It seems like what you need to do is assign the return value of getch() to 'ch' inside the loop then evaluate it. For example:



while(1) {
ch = getch();
if(ch == 'a') {
//...