#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/