Home » U++ Library support » U++ Core » StrInt returning value
StrInt returning value [message #59848] |
Wed, 03 May 2023 08:06  |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
it seems that StrInt() return an integer but it can return even a Null in case the conversion cannot be done.
I would like that StrInt() can return 0 as default instead of Null.
Do we have an alternative version of StrInt() that return 0 as default?
StrInt is based on ScanInt
int ScanInt(const char *ptr)
{
int x;
bool overflow = false;
return ScanInt<char, byte, uint32, int, 10>(x, ptr, overflow) && !overflow ? x : Null;
}
The syntax is too complicated for me. I wonder if the following version can return 0 as wanted
int ScanInt0(const char *ptr)
{
int x;
bool overflow = false;
return ScanInt<char, byte, uint32, int, 10>(x, ptr, overflow) && !overflow ? x : 0; //<----
}
Thanks,
Luigi
[Updated on: Wed, 03 May 2023 08:13] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun May 11 17:44:26 CEST 2025
Total time taken to generate the page: 0.00981 seconds
|