Link to home
Start Free TrialLog in
Avatar of RahulKajave
RahulKajave

asked on

Convert string to integer

Is there any C++ function which will convert wide char string to int. If wide char string is double "100.01" then function should return error. I can use isDigit and add own logic to validate this but wanted to check whether there is any in build function for the same. I am using VC++ on windows.
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RahulKajave
RahulKajave

ASKER

What about localization? Will strtol and stringstream handle localization properly. What if decimal separtor is "," instead of ".".
Yup. In both cases the constraint is 'non-numeric character', regardless of the localization.
Do you still have issues with this or have you just not thought of closing the question?
// What about localization?
You can write a function to replace the special characters(, with .) and then pass through stringstream to get the double/int value if needed as specified above by JKR.
Um, integers won't have a double-type separator such as a comma or a semicolon in the 1st place ;o)