sprintf(9)
π sprintf(9) π
okay bestie, welcome to the Kernel API Manual β yes, we're doing kernel docs now, and honestly? iconic of us. π
β¨ NAME β¨
sprintf β format a string and drop it right into a buffer π«Ά
πΈ SYNOPSIS πΈ
int sprintf (char *buf , const char *fmt , ... );
π¦ ARGUMENTS π¦
bufβ the buffer where the finished result goes. this is the lil home for your output πfmtβ the format string you're using. the blueprint, the vibe, the template β¨...β the arguments for that format string. the actual content filling in the blanks π
π DESCRIPTION π
so the return value? it's the number of characters written into buf, not including the trailing ' '. lowkey important, don't sleep on it π
π¨ bestie listen to me: usesnprintforscnprintfinstead so you don't get buffer overflows. like, genuinely.sprintfdoes not check anything and will absolutely let you write past the end of your buffer π that's not a vibe.
and if you wanna know about format string extensions that go beyond C99? go read the vsnprintf documentation, it's all laid out there πβ¨
π SEE ALSO π
- kernel file
./lib/vsprintf.cβ the source, the origin story π§ simple_strtoull(9)simple_strtoul(9)simple_strtol(9)simple_strtoll(9)vsnprintf(9)vscnprintf(9)snprintf(9)scnprintf(9)vsprintf(9)vbin_printf(9)bstr_printf(9)vsscanf(9)sscanf(9)
like a whole friend group of format functions, and yes they all ate π π₯
okay that's the whole page, you're officially smarter than you were three minutes ago, proud of you fr fr π
signing off from ./lib β October 2026 β this was sprintf(9), mwah ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms