我们怎样才能在变量声明中使用print()函数? [英] How can we use print() function in declaration of variable?
本文介绍了我们怎样才能在变量声明中使用print()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
main ()
{
int k, m=5;
k= printf(" ") + m;
cout<<endl<<k;
}
我的尝试:
输出6怎么样?没什么好说的只是设法制作30个单词。
What I have tried:
Output comes 6 how? nothing to say more just managing to make 30 words.
推荐答案
写在 printf文档 [ ^ ]:
Written in the printf documentation[^]:
成功时,返回写入的字符总数。
On success, the total number of characters written is returned.
请参阅 printf - C ++参考a> [ ^ ]描述:
See the printf - C++ Reference[^] description:
Quote:
返回值
成功时,返回写入的字符总数。
Return Value
On success, the total number of characters written is returned.
您正在打印一个字符(空格),所以 printf()
返回1.然后添加 m
的值,即5并将结果分配给 k
。
You are printing one character (a space), so printf()
returns 1. You then add the value of m
which is 5 and assign the result to k
.
这篇关于我们怎样才能在变量声明中使用print()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文