所以我一直在這一點,我有點難倒我得到「未初始化的局部變量加侖使用」。在我的take_Input函數轉換(加侖);在C語言中使用未初始化的局部變量
我知道這意味着加侖的價值不被認可。
爲什麼加侖升功能沒有爲加侖設置一個值,以便轉換函數具有該值。任何幫助讚賞感謝...
代碼:
double take_Input(void)
{
double a, b, c, d;
double gallons;
printf("please enter how many liters of A: ");
scanf("%lf", &a);
printf("please enter how many gallons of B: ");
scanf("%lf", &b);
printf("please enter how many liters of C: ");
scanf("%lf", &c);
printf("please enter how many gallons of D: ");
scanf("%lf", &d);
gallons_To_Liters(a,b,c,d);
conversions(gallons);
return(0);
}
double gallons_To_Liters(double a, double b, double c,double d)
{
double gallons, liters;
liters = a + c;
gallons = b + d;
gallons = (liters * 3.79) + gallons;
return(0);
}
double conversions(double gallons)
{
double totalGallons = gallons;
double quarts = totalGallons * 4;
double pints = totalGallons * 8;
double cups = totalGallons * 16;
double fluid_ounces = totalGallons * 128;
double tablespoons = totalGallons * 256;
double teaspoons = totalGallons * 768;
// output statements.
printf("the amount of gallons is: %.2f \n", totalGallons);
printf("the amount of quarts is: %.2f \n", quarts);
printf("the amount of pints is: %.2f \n", pints);
printf("the amount of cups is: %.2f \n", cups);
printf("the amount of fluid ounces is: %.2f \n", fluid_ounces);
printf("the amount of tablespoons is: %.2f \n", tablespoons);
printf("the amount of teaspoons is: %.2f \n", teaspoons);
return (0);
}
也許你應該熟悉* scope *的概念。 – EOF
@EOF也許當地是美國加侖.. –
當你有2加侖的應用程序時,誰需要10加侖的帽子? –