51中sprintf函数转换错误问题

来源:互联网 发布:魁北克大学知乎 编辑:程序博客网 时间:2024/06/03 23:38
51使用sprintf函数时有字节对齐问题,ARM中则不存在。所以51中需注意格式:char year,month,day;sprintf(buf,"%lld-%lld-%lld",(Uint32)year,(Uint32)month,(Uint32)day);<span style="white-space:pre"></span>对sprintf(buf,"%02lld-%02lld-%02lld",(Uint32)year,(Uint32)month,(Uint32)day);<span style="white-space:pre"></span>对sprintf(buf,"%d-%d-%d",(Uint32)year,(Uint32)month,(Uint32)day);<span style="white-space:pre"></span>错误sprintf(buf,"%lld-%lld-%lld",year,month,day);<span style="white-space:pre"></span>错误



0 0
原创粉丝点击