Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
PaulDavisThe1st
on Jan 22, 2022
|
parent
|
context
|
favorite
| on:
The case for a modern language
strto*() is the wrong API to use if you care about errors.
char* forty_two = 42; int i; if (sscanf (forty_two, "%d", &i) != 1) { /* error */ }
Sometimes, there's more than one way to skin a cat, and one of them is more suited to the task at hand.
JulianMorrison
on Jan 22, 2022
[–]
Now what happens if you pass it a string without a null byte terminator?
PaulDavisThe1st
on Jan 23, 2022
|
parent
[–]
I made no claim that using sscanf instead of strto* fixes all the issues with C string represenation.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: