As soon as this program gets to the scanf line that has a precision specification, it jumps to the end of the program. I assume that a character is somehow getting into the subsequent scanf and getchar, but I don't see how that would happen. Can anybody tell me what is happening here? Also if I put a space between %lf and %*c it takes 2 enter presses to proceed and I don't know why that is either.
Thanks
Code:
#include <stdio.h>
#define STORE_NAME "Sierra Sporting Goods"
int main(void){
int intNumber, intType, intQuantity;
double dblCost, dblPrice;
printf("%s\n", STORE_NAME); /*prompt for input*/
printf("\n\nEnter the product number: ");
scanf("%04d%*c", &intNumber);
printf("\nEnter the product type: ");
scanf("%d%*c", &intType);
printf("\nEnter the quantity: ");
scanf("%d%*c", &intQuantity);
printf("\nEnter the cost: ");
scanf("%.2lf%*c", &dblCost); //<==== the .2 is my problem
printf("\nEnter the price: ");
scanf("%.2lf%*c", &dblPrice); //<==== the .2 is my problem
printf("\n\nThe product number is %d", intNumber); /*Display values*/
printf("\nThe product type is %d", intType);
printf("\nThe quantity type is %d", intQuantity);
printf("\nThe cost is %lf", dblCost);
printf("\nThe price is %lf", dblPrice);
printf("\nPress enter to continue\n");
getchar();
return 0;
}