3 ms·
If that's an error then so is passing in a non number. So catch 22. You can only check for valid numbers if the number is valid?
by thomashabets2 5mo ago
If that's an error then so is passing in a non number.
So catch 22. You can only check for valid numbers if the number is valid?
- imtringued 5mo agoThat's the C way, yes.
- thomashabets2 5mo agoNo. This is more like if strcmp compared null terminates strings, but can only compare strings that are in fact equal.
- rbanffy 5mo agoIf you pass a negative number as a string to a function that converts strings representing positive numbers into positive long integers, then yes, it should return an error status instead of the wrong result.
- thomashabets2 5mo agoAh, I misunderstood what you meant by "is an error". Agree.