I'm working on an algebra application, very similar to what graphing calculators can do.
struct quotient NewQuotient()
{
struct quotient temp;
printf("Enter the numerator\n");
scanf("%d", &temp.numerator);
printf("Enter the denominator\n");
scanf("%d", &temp.denominator);
return temp;
}
char NewVarname()
{
char temp;
printf("Enter the variable letter: \n");
scanf("%c", &temp);
return temp;
}
struct term NewTerm()
{
struct term temp;
printf("Enter the coefficient: ");
temp.coefficient = NewQuotient();
printf("Enter the variable name: \n");
temp.varname = NewVarname();
printf("Enter the power: ");
temp.power = NewQuotient();
return temp;
}
The program gets the quotients for the coefficiant and powers just fine, but there's a problem with getting the variable name. I'm thinking there's a null character stuck in the buffer after the scanf statements in NewQuotient but if there are are, I don't know how to find them or how to fix them. Any help is appreciated.
scanf("%c", temp.varname);
bescanf("%c", &(temp.varname));
?