this post was submitted on 05 Apr 2025
145 points (88.4% liked)
Programmer Humor
27215 readers
399 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
printfis superior and more concise, andsnprintfis practically the only C string manipulation function that is not painful to use.Try to print a 32-bit unsigned int as hexadecimal number of exactly 8 digits, using
cout. You can dostd::hexandstd::setw(8)andstd::setfill('0')and don't forget to usestd::decafterwards, or you can just, you know,printf("%08x")like a sane person.Just don't forget to use
-Werror=formatbut that is the default option on many compilers today.C++23 now includes
std::printwhich is exactly likeprintfbut better, so the whole argument is over.I went digging in cppref at the format library bc I thought c++20 or c++23 added something cool.
Found
std::printand was about to reply to this comment to share it bc I thought it was interesting. Then I read the last sentence.Darn you and your predicting my every move /j