多头的 printf
我实现了 myPrintf 函数:
int myPrintf(const char* format,...)
{
va_list args;
va_start(args, format);
int ret = vprintf (format, args);
fflush(stdout);
va_end (args);
return ret;
}
当我使用 format = "%ld,%ld" 运行该函数时 作为字符集的 args
表示形式为 78,97,188,0,0,0,0,0,120,10,227,5,0,0,0,0
打印到 stdout 的输出是 12345678,0
。而不是 12345678,98765432
。 可能是什么问题?如何解决?
I implemented myPrintf function:
int myPrintf(const char* format,...)
{
va_list args;
va_start(args, format);
int ret = vprintf (format, args);
fflush(stdout);
va_end (args);
return ret;
}
When I run the function with format = "%ld,%ld"
and the args
representation as set of chars is 78,97,188,0,0,0,0,0,120,10,227,5,0,0,0,0
the output printed to stdout is 12345678,0
.Instead of 12345678,98765432
.
What could be the problem?And how could it be solved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为,就像在 ideone 上一样,您的
long
是 32 位http://ideone.com/jjafU
如果您使用 64 位的
"%lld"
-位值,它按您的预期工作http://ideone.com/BYTaa
Because, like on ideone, your
long
s are 32 bitshttp://ideone.com/jjafU
If you use
"%lld"
for 64-bit values, it works as you expecthttp://ideone.com/BYTaa