• Advertisement

Archived

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

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

This topic is 5271 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
no wait sorry that does not work


[edited by - kappa on August 16, 2003 12:30:04 PM]

Share this post


Link to post
Share on other sites
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
Well, maybe it is called so because it means something like "a(ny thing) to i(nteger)" --> a + to + i = atoi

cu

Share this post


Link to post
Share on other sites
Hmm thats why i didnt see it, i was looking for one letter initials, so not expecting the ''to'' to me mean to. I feel kinda dumb now..

-J

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ASCII to integer would be logical. since it only works on ASCII strings.

i''m a lurker.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
alphanumeric to integer

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Array to Integer....

Share this post


Link to post
Share on other sites
atoi - alpha to int.
itoa - int to alpha.

Edit: ohh and by alpha they mean a string.


An ASCII tetris clone... | AsciiRis

[edited by - Tiffany Smith on August 16, 2003 4:28:24 PM]

Share this post


Link to post
Share on other sites
I don''t think its alpha...

atoi = ASCII [string] To Integer
similar to...
wtoi = Wide [string] To Integer

Share this post


Link to post
Share on other sites
ap is right. boost::lexical_cast converts a string into ANY other datatype without beeing noticeable slower then C''s converting functions.

Share this post


Link to post
Share on other sites

  • Advertisement