this post was submitted on 31 Aug 2025
330 points (96.6% liked)

Programmer Humor

26175 readers
1032 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

founded 2 years ago
MODERATORS
 

Finally I have a valid reason to learn about memory management. It was also hella weird when encountering it.

you are viewing a single comment's thread
view the rest of the comments
[–] LedgeDrop@lemmy.zip 17 points 6 days ago (2 children)

Without getting too critical of your code (congrats BTW), never use strcpy instead use strlcpy.

strcpy will happily allow you to create buffer overflows (a common challenge with C) which will cause your application to crash.

You'll find more details here.

Good luck!

[–] cows_are_underrated@feddit.org 10 points 6 days ago

Thanks, I did not knew this. I always appreciate constructive criticism. I am quite new to C so theres a shit ton of stuff I have never done or dont even know about.

[–] ozymandias117@lemmy.world 6 points 6 days ago

And understand when you can use them...

I've seen too much code following this advice blindly that just does something like

strncpy(dst, src, strlen(src))