this post was submitted on 21 Aug 2023
26 points (100.0% liked)
Programming
17450 readers
143 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Hello, ewroiugheqripougheqpiurghperiugheqrpiughqerpuigheq,
The fgets function will only read in as many characters as you tell it to (50) in the second parameter, so the rest of the input will simply be lost and the name will be truncated.
And, mind you,
fgets
is the safer replacement to the originalgets
, which attempts to read a variable-length line into a fixed-length buffer.The manual has this to say about
gets
—Why is this even still in the library 🥲
Twenty years ago it kind of made sense. Ok it's bad, but sometimes we're just reading a local file fully under our control, maybe from old code that the source doesn't exist anymore for, it's such a core function that taking it out however badly needed will have some negative consequences.
At this point though, I feel like calling it should just play a loud, stern "NO!" over your speakers and exit the program.
The linker will complain at you —