因此,無論何時我嘗試在gedit中編譯該程序,它都可以正常工作(沒有錯誤)。但是,當我嘗試使用./prgram執行它時,它只是跳到終端中的下一行。我不確定是否該程序無法正常工作,或者它與我的編譯器有關。謝謝! (這是一個家庭作業,與臨時演員這麼裸露的,因爲他們所必需的全部學分)程序將無錯地編譯,但不會執行。怎麼了? (在C)
#include <stdio.h>
const double CEL = 32;
const double KEL = 459.67;
double FahToCel(double);
double FahToKel(double);
int main()
{
double cel;
double kel;
double faren;
char i[1] = "a";
while (i == "a")
{
printf("Enter a temperature in farenheit(enter s to stop):\n");
scanf("%lf\n", &faren);
printf("%lf Farenheit is equal to %lf Celsius, and %lf Kelvin\n", faren, FahToCel(cel), FahToKel(kel));
if (kel <= -274)
printf("Atomic motion has stopped\n");
else if ((kel >= -274) && (kel <= 273))
printf("Water freezes here\n");
else if ((kel >= 274) && (kel <= 280))
printf("You'll need a sweater\n");
else if ((kel >= 281) && (kel <= 294))
printf("A bit chilly\n");
else
printf("Ahh, that's better\n");
}
return 0;
}
double FahToCel(double faren)
{
double cel;
cel = (faren - CEL) * 5/9;
return cel;
}
double FahToKel(double faren)
{
double kel;
kel = (faren + KEL) * 5/9;
return kel;
}
如何你編譯它?你肯定不會在gedit中編譯它... – chris 2015-02-23 04:18:23