• Advertisement

Archived

This topic is now archived and is closed to further replies.

From char* to int???? How???

This topic is 5363 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
If you want a number in the string converted to a int theres a function call atoi() i think, which converts a number in the string and returns it as a int. Look it up on MSDN for more info.

-J

[edited by - jason2jason on August 16, 2003 12:46:18 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
char* to int
sscanf(string, "%i", &Number);

int to char*
sprintf(string,"%i",Number);

Share this post


Link to post
Share on other sites

#include <sstream>

//...

const char* blah = "25";
istringstream iss;
iss.str(blah);
int num = 0;
iss >> num;
//...



num is now equal to 25.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
boost::lexical_cast

Share this post


Link to post
Share on other sites
I''ve actully only recently memorized what atoi() does, but does anyone know why it is called atoi? Does it stand for something, or was it randomaly pressed keys(unlikly)..

-J

Share this post


Link to post
Share on other sites

  • Advertisement