I have had problems with printchar before. I think i grabs the enter after you type a char. Im not sure how to explain this problem to you, but ill show you how i usually fix it(patch).
Code:
int main(){
int number1,number2,dump;
/*Simple infinite loop prompting for values and outputting them*/
while(1){
puts("\nEnter number1\n");
number1 = getchar();
dump = getchar(); //using dump to store \n
printf("this is number1\n");
putchar(number1);
puts("\nEnter number2");
number2 = getchar();
dump = getchar(); //using dump to store \n
printf("this is number2\n");
putchar(number2);
}
return 0;
Now comment out the two instance of
and see how it behaves different.
Ived used this patch for quite some time. To lazy to actually research. A proper explanation would be interesting.
Bookmarks