Format Specifiers List

Most Commonly Used Format Specifiers:

Specifier

What it does

Most common modern usage example

Notes / Very common variants

%d or %i

Signed decimal integer

printf("Age: %d\n", age);

%d is slightly more common today

%s

Null-terminated string

printf("Name: %s\n", name);

By far the most used non-numeric specifier

%f

Floating-point (decimal notation)

printf("Pi ≈ %.2f\n", 3.14159);

Often used with precision: %.2f, %.3f

%c

Single character

printf("Initial: %c\n", ch);

Very frequent for single chars

%lld

Signed 64-bit integer (long long)

printf("Big number: %lld\n", fileSize);

Extremely common in 2025 (64-bit era)

%u

Unsigned decimal integer

printf("Count: %u\n", items);

Used when values are guaranteed non-negative

%zu

size_t (unsigned size type)

printf("Length: %zu\n", strlen(str));

Dominant choice for sizes, lengths, counts

%p

Pointer/address (usually hex)

printf("Ptr: %p\n", (void*)ptr);

Essential for debugging pointers

    printf("int:         %d\n",        n);          // 42
    printf("string:      %s\n",        name);       // Alice
    printf("float:       %.3f\n",      pi);         // 3.142
    printf("char:        %c\n",        initial);    // A
    printf("size_t:      %zu\n",       len);        // 5
    printf("long long:   %lld\n",      huge);       // 1234567890123
    printf("pointer:     %p\n",        ptr);        // (some hex address)
    printf("hex:         0x%X\n",      255);        // 0xFF
    printf("percent:     100%%\n");                 // 100%

Last updated