请问下面的程序:
double x;
scanf("%f",&x);
为什么会出错,难道输入double型数据不是用%f吗?还有我在一个枚举类型中声明了一项div,而我又要用到stdlib,结果是变量名冲突,请问有什么方法可以解决?

解决方案 »

  1.   

    %ld, %e, %E, %g, %G都可以,其实%f也是可以的。如果你英文不错,不妨看看以下说明:e  double Signed value having the form [ – ]d.dddd e [sign]ddd where d is a single decimal digit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and sign is + or –. 
    E double Identical to the e format except that E rather than e introduces the exponent. 
    f double Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision. 
    g double Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it. 
    G double Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).