In the struct definition, int weightInMeters;
should be int weightInKilos;
.
This line doesn't do anything:
(*x).weightInKilos;
It is like writing: 1 + 1;
. What was your intention here? (Technically this line causes undefined behaviour for evaluating an uninitialized variable).
char name;
scanf("%s", &name);
The declaration char name;
means that name
is a single character. But scanf("%s"
tries to read several characters. This will cause a buffer overflow with unpredictable consequences. Replace those with:
char name[100];
scanf("%100s", name);
This line:
scanf("%d", &weightInKilos);
I assume you meant
scanf("%d", &x->weightInKilos);
Finally, in this line:
printf("%s has a BMI of = %.2f\n", &name, xBMI);
&name
should just be name
.