Printf in C is so BAD I had a Crash Out
@tsoding121K followers
59,036 views
33 Comments
Comments from the original post on X (Twitter)

@maxxkph
careful, crashing out in C is undefined behavior
25 likes

@tsoding
Follow me on Twitch for more crash outs
17 likes

@kabutuo59766
Who is he, I want to follow him
10 likes

@kabutuo59766
Lol. I will watch you twitch when I have time
2 likes

@w______roy
I never understood why it doesn’t give you the number of args when that is always known at compile time.
9 likes

@borrowck_novel
Although the bar is extremely low, it didn't stop Jai to make it's print system even worse.
9 likes

@PurnyaMeow
I wasn't aware of the horrors printf could hide, holy shit
6 likes

@StirringDragon
C was not designed with security in mind, it was designed with low level control in mind, as was any language that gave you access to pointers. That said, printf still rules from an ease of use perspective. C++'s cout was a sick joke on programmers.
3 likes

@mikpom_
As someone far from CS this how I demarcate high- low-level programming languages: by how easy is it to print shit.
2 likes

@CaptAmericaTx
There is a way to sort of find the end of the variadic list. In main, register a signal handler for segmentation fault, and in the signal handler do a longjmp() to the instruction following the variadic for loop. Not 100% reliable, but if it is 2am and project is due at 8am... 🙃
2 likes

@Zorkimer
I just replaced it. Literals just memcpy'd, no string parsing at all, no UB from accidentally %ing the wrong type, no different identifiers on windows and linux. Just make your own thing and call the OS's write().
2 likes

@papavo
It's C, you can roll your own printf.
2 likes

@GodLancelot91
Honestly, all the replacements are terrible like std::fmt/fmtlib, etc. All parse string formatter metadata at runtime and because of that are WAY too heavy for some important enviroments.
1 like

@weryfrate
@grok Why did he crash out?
1 like

@tosho
dude, wtf is this thumbnail?! It's genius :D
1 like

@giacomomasseron
which one crashed you out, the format specifiers or the varargs not checking anything
1 like

@7alken2
))

@24meebo
amazing how much a simple tagged union type solves

@fctsMttrLsShttr
Still more fun to work with than shifting formatting attributes to cout. This week I had an issue with printf. Turns out %llu did not work by default in my embedded compiler. I even used PRIu64. No compiler warning or error. It just printed "lu" at runtime instead of a number.

@bitcoinOrBTC
You had a crush












