Top "Printf" questions

`printf` is a common function for formatted output.

Printing " (double quote) in C

I am writing a C code which reads from a file and generates an intermediate .c file. To do so …

c printf double-quotes quote
Determining sprintf buffer size - what's the standard?

When converting an int like so: char a[256]; sprintf(a, "%d", 132); what's the best way to determine how large a …

c int printf
sprintf() with automatic memory allocation?

I'm searching for a sprintf()-like implementation of a function that automatically allocates required memory. So I want to say …

c malloc printf
Making a table with printf in c++

I'm trying to make a table like this.... (Just without the dots I used to separate the each item) Weekly …

c++ printf text-alignment
How to left justify text in Bash

Given a text, $txt, how could I left justify it to a given width in Bash? Example (width = 10): If $txt=…

bash printf justify text-justify
What is the purpose of the h and hh modifiers for printf?

Aside from %hn and %hhn (where the h or hh specifies the size of the pointed-to object), what is the …

c printf variadic-functions promotions format-specifiers
What's the difference between printf("%s"), printf("%ls"), wprintf("%s"), and wprintf("%ls")?

Consider this sample program: #include <cstdio> #include <cwchar> #include <string> int main() { std::string …

c++ unicode printf widechar
sprintf function's buffer overflow?

{ char buf[8]; sprintf(buf,"AAAA%3s","XXXXXXXX"); printf("%s\n",buf); } What will happen? The buffer has 8 characters worth of …

c printf overflow fortify-source
error: aggregate value used where an integer was expected

I am having following union union data { uint64_t val; struct{ .... } }; and I have a function func(union data mydata[]) { …

c linux printf unions format-specifiers
What's the proper use of printf to display pointers padded with 0s

In C, I'd like to use printf to display pointers, and so that they line up properly, I'd like to …

c pointers printf c99