r/programminghorror • u/EvidenceFearless6800 • Apr 08 '26
c++ reference tables were non-existent to 15-year-old me
149
Upvotes
r/programminghorror • u/EvidenceFearless6800 • Apr 08 '26
140
u/Great-Powerful-Talia Apr 08 '26
You don't need a reference table, this can be done by just editing the string.
71
u/NaCl-more Apr 08 '26
String interpolation crying in the corner
52
u/vanit Apr 08 '26
Heh this kind of crap is basically a rite of passage.
11
u/fuj1n Apr 08 '26
Assuming this is before std::format and you didn't include fmt in your project (which would make this nicer) this can be easily done with just concatenation and there's a toupper function in cctype for your forceUppercase case.
No need for reference tables.
3
u/Environmental-Ear391 Apr 08 '26
And personally I went and used Math on any 8bit value in the ASCII "a~z" range to make it the "A~Z" range...
Because, first programming language was C, second was 680x0 Assembler, never really "got it" with BASIC style languages with enforced DataType separation.
2
u/ZylonBane Apr 08 '26
And apparently you call arrays "reference tables".
2
u/Informal-Chance-6067 Apr 08 '26
At one point, I was attempting to make a Rubik’s cube simulator and had to hardcode all the transformations. I probably should have used some sort of loop.
2
u/shponglespore Apr 08 '26
This reminds me of when I was a kid and I tried to code map data in GW-Basic by using a bunch of "if x=... and y=..." statements. I had the drive to program, but I lacked so much knowledge!
2
u/conundorum Apr 09 '26 edited Apr 10 '26
Yeah... kinda crazy when we start with big fat tables like that, then learn that we can simplify it to something like this:
One of the best ways to see how much you've improved is when you go back and look at your old code, and realise it belongs on this sub. It was pretty good for a 15-year-old, but it must feel really quaint to you now. ;P
Edited to fix an off-by-one error, oops.1
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Apr 09 '26
Are those actual paths on the filesystem?
1
u/barthanismyname Apr 09 '26
There should be an r/programmingaddressme subreddit
1
u/SpellOutside8039 Apr 11 '26
at least now you learn
1
u/rsvallen Apr 12 '26
One of the cool things of AI is that you can make "stupid" questions to avoid things like this when you are starting.
I actually felt really afraid of posting on Stack overflow a few years ago because of all the videos showing the hate people got 😭
0
u/namtabmai Apr 08 '26
Also apparently case fallthrough?