Strings In Depth15 / 18
Up next

snprintf

#include <stdio.h>

int main(void) {
    char buf[32];
    int written = snprintf(buf, sizeof buf, "%s #%d", "item", 7);
    printf("%s (%d chars)\n", buf, written);
    return 0;
}
What you're solving

format into a buffer without overflow