私はC言語の学習に取り組んでおり、最近完成したPythonの本の練習問題を使っています。私のCの本は郵便に入っていますが、私は頭を打ちたいと思っていました。私は簡単な温度変換プログラムを組み立てていました。なぜなら何らかの理由でそれがいつも私の条件の 'Else'句にジャンプしています...私は何か単純なものが欠けていると確信していますが、それを理解できないようです。任意のアイデア?:C - 条件付きで常に「Else」にジャンプしますか?
#include<stdio.h>
main()
{
float temp_c, temp_f;
char convert_from[1];
printf("Convert from (c or f): ");
scanf("%c", &convert_from);
if(convert_from == "c")
{
printf("Enter temperature in Celsius: ");
scanf("%f", &temp_c);
temp_f=(1.8*temp_c)+32;
printf("The temperature in Fahreinheit is: %f \n", temp_f);
}
else if(convert_from == "f")
{
printf("Enter temperature in Fahreinheit: ");
scanf("%f", &temp_f);
temp_c=(temp_f/1.8)-32;
printf("The temperature in Celsius is: %f \n", temp_c);
}
else
printf("Invalid choice. \n");
}
する必要があり、それは他の決勝にジャンプします。 – cgc