Hi all,
I am a new programmer so sorry if this is an annoying question. I would very much appreciate your help with the following. I am trying to get a user to input values for a created structure type called car_t. When I input random values the string input works for the newcar.make (it prints exactly what I entered), but whatever I put in for newcar.price it always prints that the value is 0.00000.
Here's my code:
Code:
#include <stdio.h>
#include <string.h>
typedef struct {
double price;
char make[50];
}car_t;
int main()
{
car_t newcar;
printf("Input make of car: ");
fgets(newcar.make, 50, stdin);
printf("\nInput price of car: ");
scanf("%lf", &newcar.price);
printf("The make is: %s", newcar.make);
printf("The price is: $%lf", newcar.price);
return 0;
}
Thanks for your help.