Does anyone know how I can print and count the number of characters that I printed?
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?
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.
printf returns the number of characters it printed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With