返回用C printf()函数的值 [英] Return value of printf() function in C

查看:105
本文介绍了返回用C printf()函数的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的printf()函数将返回打印的字符数。但在下面的code
为什么它打印5。

The printf() function will return the number of characters printed. But in the code below why is it printing 5.

int a=1000;
printf("%d",printf("\n%d",a));

它打印出1000曾经和一个空格,所以干脆我们有2个字符。

It prints "1000" once and a space, so altogether we have 2 characters.

它应该输出1000 2。但其输出1000 5。

It should output "1000 2". But its outputting "1000 5".

推荐答案

输出的字符数为5 1000 是四个字符。 \\ n 是一个字符。

The number of characters output is 5. 1000 is four characters. \n is one character.

的printf 不返回的物品的个数,如 scanf函数系列函数输出输入做。它返回实际的字符数。

printf doesn't return the number of "items" output like the scanf family of functions do for input. It returns the actual character count.

这篇关于返回用C printf()函数的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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