Is there any API to check if any number exceeds it’s range?
My number is stored as string. char *ptr = "123456789"
API should do: int a = api(ptr, long) if a==-1 suppose value exceeds.
Please note: We can’t parse the string and check because it will automatically wrap it to the other side, and make it within the range.
Thanks in advance
Please checkout strtol and strtoul.
See this example:
Edits:
inttolongforbandd.errnoto0before calling into c library.LONG_MINalso for errors.