相关疑难解决方法(0)

来自printf的长long int的结果不一致?

struct DummyStruct{
        unsigned long long std;
        int type;
};

DummyStruct d;
d.std = 100;
d.type = 10;

/// buggy printf, unsigned long long to int conversion is buggy.
printf("%d,%d\n",d.std, d.type);  // OUTPUT: 0,100 
printf("%d,%d\n", d.type, d.std); // OUTPUT: 10,100 
printf("%lld,%d\n",d.std, d.type); // OUTPUT: 100,10
Run Code Online (Sandbox Code Playgroud)

请告诉我为什么在printf中没有正确处理unsigned long long to int转换.我正在使用glibc.

这是printf中的错误吗?

为什么printf不进行内部类型转换?

c c++ printf

1
推荐指数
3
解决办法
1395
查看次数

标签 统计

c ×1

c++ ×1

printf ×1