用scanf如何读入long double和unsigned char? 语言学得不精,还请众神指点…… 网上找了一下,可是照着打不行啊。。。 以下是代码和编译信息(c++)
#include <cstdio>
int main()
{
unsigned char test;
scanf("%hhu",&test);
printf("%hhu",test);
long double a;
scanf("%Lf",&a);
printf("%lf",a);
}
MINGW is broken regarding long double. I had reported this myself some time ago, and in summary here is what is going on:
In Windows world double and long double is the same. However in MINGW long double is larger than double, however (I do not know more specifics) it can print only the long double of MS Windows, that is the double.
They are using an MS library or something. You have two options. Either stick to double which is the same in Windows world, or use DJGPP which is another GCC port (but creates 32-bit DOS executables).
Or use some other compiler.
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。