-2
#include <stdio.h>
int main(void)
{
double height; //Error happens if I write double height instead of float height!
printf("Height(inch): ");
scanf("%f",&height);
printf("%f inch = %f cm \n",height,height*2.54);
}
コメントのように、浮動小数点数の代わりに倍精度浮動小数点数を書くとエラーが発生します。私のコードに何が問題なのですか?double、float変数代入に関するCのエラー
「scanf」のマニュアルページから分かりませんでしたか? – Olaf
http://stackoverflow.com/questions/4264127/correct-format-specifier-for-double-in-printf受け入れられた答えを(少なくとも最後の部分)読みます。 – 4386427