c - 额外的零作为输出

标签 c

#include <stdio.h>
#include <stdlib.h>
int main()

{
char *str="Helloworld";
printf("%d",printf("%s",str));
return 0;
}

这个程序的输出是Helloworld10而不是Helloworld1
杂项零来自哪里

最佳答案

为什么您希望程序编写Helloworld1? 1 应该来自哪里?
the return value of functions of the printf family is the number of characters outputted (sprintf 等变体的最后一个 \0 除外)。 Helloworld 的长度为 10。

关于c - 额外的零作为输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9496661/

相关文章:

c++ - 如何检查系统()结果

c - 未处理的异常...读取位置访问冲突

Ubuntu 11.10 上的 c 数学链接器问题

分离线程的 pthread_create() 线程 ID 可以在堆栈上短暂存在吗?

c - R_X86_64_32S 和 R_X86_64_64 重定位是什么意思?

c - uint64_t 类型的问题

将字符串递归转换为整数 - C 编程

c - 运行一系列直到小数点第三位相同

c - 之前的预期表达

c - 我无法使用 cmake 和 MinGW gcc 编译器构建 gtk gui