r/C_Programming • u/Glum_Hamster_2104 • Oct 18 '26
Rename printf/scanf to print/scan?
Probably a dumb question but why hasn't there ever been a proposal to rename printf/scanf to just print? I know the f stands for format but writing print instead of printf would be slightly quicker and better to match other programming languages as I often miswrite printf as print as I also code in Python.
0
Upvotes
21
u/EpochVanquisher Oct 18 '26
One of the main goals of C is to keep existing code working.
C also puts every function in a single global namespace.
If you name a function print() in the standard library, it will break the code of everyone who already has a function named print(). This is bad, so the language committee doesn't do it.
There are, like, a million things wrong with C and people have successfully fixed most of them, but the result is a different language with a different name.
15
u/bothunter Oct 18 '26 edited Oct 18 '26
#define print printf
Edit: coding on a phone is hard. Thank you u/hugonikanor
3
u/Direct_Chemistry_179 Oct 18 '26
Could be a fun project to hack existing libc urself. Not sure how, but I saw someone do this with tcc to remove semicolons.
3
u/Daveinatx Oct 18 '26
Think about why it's called
printf/scanfvs let's sayputsandputc. The 'f' stands for formatted.You'll also find
openvsfopenetc.I strongly recommend for you to get used to C's nomenclature. If you ever work in a team project in C, you'll want to maintain consistency for readability.
5
u/questron64 Oct 18 '26
Yes, let's break almost 50 years of code for no good reason. Sounds like a plan.
5
u/onesole Oct 18 '26
2
u/MegaDork2000 Oct 18 '26
Why not use
.like Forth? That way people used to Forth will not keep making typos when they want to print something, am I right?2
u/SmokeMuch7356 Oct 18 '26
50+ years of legacy code says "no".
It's why all the string processing functions still sound like indigestion noises (
srpbrk,strcspn, etc.). When C was initially designed, external names couldn't be longer than 8 characters. That's obviously no longer the case, but nobody's going to rename anything in the string library because 50+ years of legacy code.Now, you could do something like
and be on your merry way, although I can't promise it won't plant time bombs that show up at really awkward times.
But nothing in the standard library is going to be renamed. Ever.
3
u/tubameister Oct 18 '26
claude, submit a proposal to rename printf/scanf to just print
1
u/Gold-Part4688 Oct 18 '26
bro idk why i'm exposing myself on the c reddit, but c3 has print, which prints anything as what it is (even enums as strings, it's cool). Also has printn and printfn for '\n' variants
1
u/grimvian Oct 18 '26
When I started learning C char felt wrong and I had a desire to call it byte. I also missed or, and, elif but not anymore.
1
u/mwiseca Oct 23 '26
I saw some people rename printf and scanf with #define
I tried it and it worked.