Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » StrInt returning value
StrInt returning value [message #59848] Wed, 03 May 2023 08:06 Go to previous message
forlano is currently offline  forlano
Messages: 1185
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

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: CreateProcessW doesn't compile with CLANG
Next Topic: memory consumption of my application
Goto Forum:
  


Current Time: Sun May 12 22:00:25 CEST 2024

Total time taken to generate the page: 0.02675 seconds