hey.. Ive done a bit of java and im new at C... so forgive the inexperience/noobage here.. I got 2 problems, I want my program to read in 2 fractions and print the product.. and whenever I press enter without entering any value, ie. a null input, I want it to go back to the main menu.. I have left out the main menu code.. here's the rest of the relevant bits:
/****************************************************************************
* Function nullCheck() checks if a null is entered to return to menu
****************************************************************************/
void nullCheck(char cNum1[])
{
if(&cNum1[1] == NULL)
{ main();
}
}
/****************************************************************************
* Function fractions() calculates the sum of 2 fractions
****************************************************************************/
void fractions()
{
int i, nProd, dProd, iNum1, iNum2, iDen1, iDen2;
char cNum1[4];
char cNum2[4];
char cDen1[4];
char cDen2[4];
printf("Enter fraction 1: ");
scanf("%s/%s", cNum1, cDen1);
//nullCheck(cNum1);
printf("Enter fraction 2: ");
scanf("%s/%s", cNum2, cDen2);
//nullCheck(cNum2);
//printf("%d", iNum1);
//(THE PRINTF STATEMENTS ARE FOR DEBUGGING PURPOSES)
iNum1 = atoi(cNum1); //works
printf("%d", iNum1);
iNum2 = atoi(cNum2); //works
printf("%d", iNum2);
iDen1 = atoi(cDen1); //doesn't work
printf("%d", iDen1);
iDen2 = atoi(cDen2); //doesn't work
printf("%d", iDen2);
problem 1: It prints out the numerators correctly, but not the denominators.
problem 2: I can't seem to get the "enter a null and go back to the main menu" function to work.