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

2 points by DenisDolya ↗ HN
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

2 comments

[ 4.3 ms ] story [ 11.8 ms ] thread
slurping a bit too much from the AI hose.

go back to python land.

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.