#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
char wunit[2]; // weight unit
char hunit[2]; // height unit
double weight, height;
printf("Enter the body weight: ");
scanf("%lf%s", &weight, &wunit); // input weight and unit eg. 150lb
printf("Enter the height: ");
scanf("%lf%s", &height, &hunit); // input height and unit eg. 5.65 ft
printf("The height unit: %s\n", hunit);
printf("The weight unit: %s", wunit);
return 0;
}
此代码仅打印出身高单位,而不是体重单位。我能做些什么来修复它?