i just would like to ask for help regarding my code... my problem is this... the user must enter an 80-digit number...if he enters more than 80 digits, the error "\007Input number must not exceed a total of %d digits\n" will appear setting the iserror flag to 1 and breaking the for loop. then if iserror==1, it will execute the line "continue" so that the user may enter a new number... the previous number he entered is no longer valid...
the problem is, after the program prints "Enter number 1: " to take a NEW input from user, the getchar function gets the number immediately after the 80th number which the user previously entered... i wonder how can i be cleared of the previous number the user entered so that when asked again to enter number 1, the getchar will get the char starting from the first digit of the NEW input number.
while(isvalid==0){
iserror=0;
printf("Enter number 1: ");
ch=getchar();
/*check if no input for number 1*/
if(ch=='\n'){
printf("\007Please input an integer up to 80 digits\n");
continue;
}
/*check if input for number 1 exceeds maximum digit count*/
if(ch=='-'){/*signed input number 1*/
signednum1=1;
for(n=0;n<=MAXDIGITCOUNT,ch!='\n';n++){
ch=getchar();
if(n==MAXDIGITCOUNT && ch!='\n'){
printf("\007Input number must not exceed a total of %d digits\n",MAXDIGITCOUNT);
iserror=1;
break;
}
if(n<MAXDIGITCOUNT && ch!='\n'){
num1[n]=ch;
len1=n+1;
}
}
if(iserror==1){
continue;
}
}
if(iserror==1){
isvalid=0;
}
else
isvalid=1;
}