Two simple rules. Four lines of code. Perfect safety.
No more fgets() complexity. No more buffer overflows.
Two simple rules. Four lines of code. Perfect safety.
No more fgets() complexity. No more buffer overflows.
> 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.
110111011110•2mo ago
go back to python land.