如何计算作为输出打印的字符数? [英] How can I count the number of characters that are printed as output?
本文介绍了如何计算作为输出打印的字符数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道我如何打印和计数我打印的字符数?
Does anyone know how I can print and count the number of characters that I printed?
说我有一个我正在通过 printf
或 cout
。
Say I have a number I am printing via printf
or cout
. How could I count the actual number of digits I have printed out?
推荐答案
根据 printf man page ,printf返回打印的字符数。
According to the printf man page, printf returns the number of characters printed.
int count = printf("%d", 1000);
如果遇到输出错误,则返回负值。
If an output error is encountered, a negative value is returned.
这篇关于如何计算作为输出打印的字符数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文