Hey guys does anyone know why in this function i get an error at line 401 i think its at the atof function
Code:
void addStock(TennisStoreType* ts)
{
char tmpDescription[DESCRIPTION_MAX + 1];
char tmpunitPricePtr[10];
char tmpstockLevelPtr[PRICE_COLWIDTH];
float tmpPrice;
int tmpStock[STOCKLEVEL_MAX];
int finished = FAILURE;
StockNodeType* curStock = ts -> headStock;
StockNodeType* newStock;
StockNodeType* prevStock;
do
{
printf("Description: (1-40 characters)\n");
fgets(tmpDescription, DESCRIPTION_MAX + 2, stdin);
/* check the range of surname */
if(tmpDescription[strlen(tmpDescription) -1] != '\n');
{
printf("Description too long less that 12\n\n");
}
/* fails if empty line is pressed*/
if(tmpDescription[0] == '\n')
{
printf("\t\n*****back to main menu*****");
finished = FAILURE;
}
}while(tmpDescription[strlen(tmpDescription)-1] != '\n');
tmpDescription[strlen(tmpDescription)-1] = '\0';
/**** Unit Price ****/
do
{
printf("UnitPrice: (0.05-999.95)\n");
fgets(tmpunitPricePtr, POSTCODE_LEN + 2, stdin);
/* fails if empty line is pressed*/
if(tmpunitPricePtr[0] == '\n')
{
printf("\t\n*****back to main menu*****");
finished = FAILURE;
}
/* check the range of the unit pice */
if(tmpunitPricePtr[strlen(tmpunitPricePtr) -1] != '\n')
{
printf("The unit price is too long!\n\n");
readRestOfLine();
}
else
{
tmpunitPricePtr[strlen(tmpunitPricePtr) -1] = '\0';
finished = SUCCESS;
}
tmpPrice[10] = atof(tmpunitPricePtr);
/***** stock level *****/
do
{
printf("Stock Level: (1 - 100)\n");
fgets(tmpstockLevelPtr, STOCKLEVEL_MAX + 2, stdin);
/* fails if empty line is pressed*/
if(tmpstockLevelPtr[0] == '\n')
{
printf("\t\n*****back to main menu*****");
finished = FAILURE;
}
/* check the range of the stock */
if(tmpstockLevelPtr[strlen(tmpstockLevelPtr) -1] != '\n')
{
printf(" Stock level needs to be between (0 -100)\n\n");
readRestOfLine();
}
else
{
tmpstockLevelPtr[strlen(tmpstockLevelPtr) -1] = '\0';
finished = SUCCESS;
}
tmpStock[STOCKLEVEL_MAX] = atoi(tmpstockLevelPtr);
}while(finished == FAILURE);
}while(finished == FAILURE);
}