I am runing my code but it doesn't let me give it an input as i told.
I suspect it to be a buffer problem related to c language. However i tried
flushing the buffer using fflush(stdin)
before the problems input and after it.
so the first input is here:
do {
printf("Welcome to Full Adder\n");
printf("(1)Compute and display the outputs\n(2)Quiet\nYou choose: ");
scanf("%d", &QorR);
fflush(stdin);
printf("You have chosen option %d\n",QorR)
as you could see theirs an fflush there ust after i give it the input
the code with the problem is as follows:
for(A=0, B=0, C_in=0, D=0; BBase==8 ;BBase == 0){
A=0;B=0;C_in=0;D=0;
fflush(stdin);
printf("enter a number"); //"it stops exactly here"
scanf("%c",&D); //%c to be able to compare it to it's ASCII value
//i think thats why theirs
if (D > 067){
printf("Octal %d cannot be represented with 3 bits! Please try again!",D);continue;
}//go back to input
C_in=D%2;
D=D/2;
B=D%2;
D=D/2;
A=D%2;
D=D/2;
switch (A) {
case 1:
and it jumps to the end of the loop. Can someone help me with this problem? the funny thing is that it works perfectly at BBase==2, but at BBase==16&BBase==8 it doesn't, although the three of them are written the same way.
Update
I put a scanf(%d,&scrap);
just befor the enter a number
message and it waited for me to give it an input. how so?
Update
Problem solved!
Added __fpurge(stdin)
and it's working in a better way now.
Thanks to all the engagement in the comments.