▲ | orbisvicis 5 days ago | |||||||||||||
For clarity, all snprintf calls "return the number of bytes that would be written to s had n been sufficiently large excluding the terminating null byte" [1]. | ||||||||||||||
▲ | BobbyTables2 5 days ago | parent [-] | |||||||||||||
I’d argue this is one of the cursed design choices of the standard library. Way to easy to use the returned value as the “actual length” of the written string. Sure, that was never the intent, but still… The standard library also makes appending a formatted string to an existing one surprisingly nontrivial… What should be a 1-liner is about 5-10 lines of code (to include error handling) and is somewhat hard to read. The “cognitive load” for basic operations shouldn’t be high… | ||||||||||||||
|