Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can i parse an int from a string?

Status
Not open for further replies.

adi316

Programmer
Sep 10, 2002
35
0
0
CA
if so can you tell me the procedure?
 
char buffer[] = "1234";

int bufValue = atoi(buffer);

// UNICODE

int bufValue = _ttoi(buffer);

if it is a float use atof or _tcstod respectively

Matt
 
o sorry i guess is hould have mentioned im writting c++, and the <string> class.

that code gives me an error:

error C2664: 'atoi' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
 
i belive there is a cstr function of the string class that will return a constant string from the object.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top