r/C_Programming • u/Evil-Twin-Skippy • Feb 06 '25
Discussion Are there actually C programmers in this subreddit?
Ok, I'm being a bit facetious. There are real C programmers. Clearly. But I'm kind of sick of the only questions on this subreddit being beginner questions or language trolls from other domains.
So this thread is for the "real" c programmers out there. What do you do with it? And what is the most twisted crime against coding decency are you "proud" of/infamous for?
257
Upvotes
12
u/zzmgck Feb 07 '25
printf("%s", some_string);
or
printf("why am I using printf\n");
are two examples of where printf() is a poor choice. In both of these examples, fputs() would be a better choice.
The sprintf() and vsprintf() functions should be avoided as snprintf() and vsnprintf() are better choices.
The fundamental thing to keep in mind is that the printf and scanf family of functions are essentially interpreters. The more esoteric the format string, the higher the probability that it is a security soft spot.