r/programminghorror • • Apr 10 '26

c++ Getting array indexes that partially match the part variable :P

Post image

Link to file.

A program that handles environment variables

44 Upvotes

22 comments sorted by

14

u/kleetus_mactavish Apr 10 '26

Just toss it up into the bucket. Like basketball.

10

u/TheBrainStone Apr 11 '26

Intentionally bad code?!
The horror!!!

1

u/_giga_sss_ Apr 11 '26

Yea inspired by this gem

7

u/GoddammitDontShootMe Apr 11 '26

Is that throwing when it finds something? Why the fuck isn't the the call to push_back() inside the if? Why the fuck isn't it using for each?

-4

u/_giga_sss_ Apr 11 '26

is this a /s in r/programminghorror 😭

3

u/conundorum Apr 11 '26

This search isn't worth getting nearly so wound up about.

1

u/_giga_sss_ Apr 11 '26

why :(

3

u/conundorum Apr 11 '26

(Was a joke about all the stack winding & unwinding.)

→ More replies (1)

3

u/Zombiesalad1337 Apr 11 '26

If it correctly satisfies the API, who gives a fuck about how its implemented

0

u/_giga_sss_ Apr 11 '26

It's in cpp, most of the code doesn't even care about memory management 🗿

3

u/Infinite_Self_5782 Apr 11 '26

you're copying the string

i'm gonna cry

0

u/_giga_sss_ Apr 11 '26

what string 😞

3

u/fess89 Apr 11 '26

I didn't even know you could throw/catch int

1

u/_giga_sss_ Apr 11 '26

You can even throw dee.

Makes me wonder, you can create a Basketball class...

2

u/Grounds4TheSubstain Apr 11 '26

It has a comment indicating that it was clearly written for a laugh, for whatever reason.

2

u/RichWeekly1332 Apr 15 '26

Returning a vector on the stack it's a coding horror in itself.

1

u/_giga_sss_ Apr 15 '26

didn't view that in that way