Settings

Theme

Show HN: SLFG: We Made Gets() Safe. Everyone Said It Was Impossible

2 points by DenisDolya a month ago · 3 comments · 1 min read

Reader

For decades, C programmers banned gets(). We found a way.

Two simple rules. Four lines of code. Perfect safety.

No more fgets() complexity. No more buffer overflows.

See how: https://github.com/Ferki-git-creator/slfg

JohnFen a month ago

This is nonsense. The error is here:

> buffer[4] = '\n' — puts a newline at the last position

> gets(buffer) — the function stops when it hits that newline

But gets() doesn't stop when it hits that newline. It stops when a newline appears in the input stream, not in the buffer the input is being copied to.

Besides, good luck finding a modern compiler that still supports gets() at all.

  • DenisDolyaOP a month ago

    Thank you, your criticism is at least technical, another comment under this post is completely rude.

110111011110 a month ago

slurping a bit too much from the AI hose.

go back to python land.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection