sprintf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ 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: use snprintf or scnprintf instead so you don't get buffer overflows. like, genuinely. sprintf does 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 🌈

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