VISUALC ++ 6.0无符号长长和sprintf [英] VisualC++ 6.0 with unsigned long long and sprintf

查看:152
本文介绍了VISUALC ++ 6.0无符号长长和sprintf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的sprintf()在Visual C ++ 6.0(纯C)一个unsigned long long值。<​​/ P>

i want to sprintf() an unsigned long long value in visual C++ 6.0 (plain C).

char buf[1000]; //bad coding 
unsigned __int64 l = 12345678; 
char t1[6] = "test1"; 
char t2[6] = "test2"; 
sprintf(buf, "%lli, %s, %s", l, t1, t2);

给出结果。

12345678, (null), test1

(手表是无法打印测试2)

(watch that test2 is not printed)

和L = 123456789012345它提供了一个异常句柄

and l = 123456789012345 it gives an exception handle

有什么建议?

推荐答案

要打印无符号__int64 在Visual C ++ 6.0,你应该使用值% I64u ,而不是%LLI (指的此页面上MSDN )。 %LLI 仅在Visual Studio 2005和更高版本支持。
所以,你的code应该是:

To print an unsigned __int64 value in Visual C++ 6.0 you should use %I64u, not %lli (refer to this page on MSDN). %lli is only supported in Visual Studio 2005 and later versions. So, your code should be:

sprintf(buf, "%I64u, %s, %s", l, t1, t2);

这篇关于VISUALC ++ 6.0无符号长长和sprintf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆