开发者社区> 问答> 正文

用scanf如何读入long double和unsigned char?

用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);
}

展开
收起
a123456678 2016-06-06 09:43:21 2704 0
1 条回答
写回答
取消 提交回答
  • 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.
    2019-07-17 19:27:39
    赞同 展开评论 打赏
问答分类:
C++
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载