Please don't advise the use of getch(), its a non-standard function.

@Melon, change all of these:
temp = getchar();

for these:
while (getchar() != '\n');

Your input buffer isn't being cleared fully, the while loop will do that for you.