Top "Printf" questions

`printf` is a common function for formatted output.

Scanf/Printf double variable C

Let's say I have this following bit of code in C: double var; scanf("%lf", &var); printf("%lf", var); …

c double printf stdout stdin
How to display hexadecimal numbers in C?

I have a list of numbers as below: 0, 16, 32, 48 ... I need to output those numbers in hexadecimal as: 0000,0010,0020,0030,0040 ... I have tried …

c format integer printf hex
printf and long double

I am using the latest gcc with Netbeans on Windows. Why doesn't long double work? Is the printf specifier %lf …

c gcc printf long-double
Printf width specifier to maintain precision of floating-point value

Is there a printf width specifier which can be applied to a floating point specifier that would automatically format the …

c floating-point printf c99 floating-point-precision
Printing 1 to 1000 without loop or conditionals

Task: Print numbers from 1 to 1000 without using any loop or conditional statements. Don't just write the printf() or cout statement 1000 …

c++ c printf
How I can print to stderr in C?

In C, Printing to stdout is easy, with printf from stdio.h. However, how can print to stderr? We can …

c printf stderr
Left-pad printf with spaces

How can I pad a string with spaces on the left when using printf? For example, I want to print "…

c formatting printf
How to print an unsigned char in C?

I am trying to print char as positive value: char ch = 212; printf("%u", ch); but I get: 4294967252 How I can …

c printf
Difference between fprintf, printf and sprintf?

Can anyone explain in simple English about the differences between printf, fprintf, and sprintf with examples? What stream is it …

c io stream printf
printf format specifiers for uint32_t and size_t

I have the following size_t i = 0; uint32_t k = 0; printf("i [ %lu ] k [ %u ]\n", i, k); I get …

c printf