Computing.Net > Forums > Programming > string to integer

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

string to integer

Reply to Message Icon

Name: Jeff
Date: October 9, 2002 at 23:58:22 Pacific
OS: Windows XP
CPU/Ram: 128MB
Comment:

How do you convert a string with a 2 digit number to an integer. Such as:

string X = "54";
I would like an integer to have that 54. The user gives input so X is not necessarily 54, but the number will be no higher than 99.



Sponsored Link
Ads by Google

Response Number 1
Name: cup
Date: October 10, 2002 at 00:55:24 Pacific
Reply:

Try

int value = atoi(X.c_str());

You could also use strtol, strtod and strtoul but they are a bit messy.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: string to integer

String to Integer in Visual Basic www.computing.net/answers/programming/string-to-integer-in-visual-basic/5960.html

String to Integer?? www.computing.net/answers/programming/string-to-integer/11545.html

SQL string to integer conversion www.computing.net/answers/programming/sql-string-to-integer-conversion/11425.html