• Advertisement

Archived

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

casting int to string

This topic is 5344 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

Normally i use borland c++ builder and there i use the IntToStr() function But atm i''m using visual c++, what function do i use here to get this done?

Share this post


Link to post
Share on other sites
Advertisement
Try _itoa( int, char *, int ), I''m not sure what the underscore is all about, but it should work.

Kory

Share this post


Link to post
Share on other sites
itoa(int ,char*,10)
works fine
It doesn''t need an underscore.
Thx all for your help

Share this post


Link to post
Share on other sites
quote:
Original post by Pilatus
itoa(int ,char*,10)
works fine


This question gets asked every week - you should use the search facility to find previous answers. For the record, you should avoid itoa(), which is not a Standard C or C++ function. sprintf and stringstream are.

Share this post


Link to post
Share on other sites
Nah forget the search feature...It was a simple question and easy for us to answer.

If the question was DX VS OPENGL -> Use the search.

Share this post


Link to post
Share on other sites
quote:
Original post by granat
Nah forget the search feature...It was a simple question and easy for us to answer.

Even more shameful then that three people managed to recommend a non-standard function. We don't need that sort of misinformation on the boards. Last time I looked, the forum name was `For Beginners' not `By Beginners'.

[edited by - SabreMan on July 3, 2003 11:49:46 AM]

Share this post


Link to post
Share on other sites
LOL haxor this:

std::string str("543 blah");
int i = boost::lexical_cast<int>(str);


[edited by - 666_1337 on July 3, 2003 12:15:04 PM]

Share this post


Link to post
Share on other sites
The best way using C is strtol or strtoll in stdlib.h

char *stringToConvert;
char *endPointer;
long integer;

integer = strtol(stringToConvert, &endPointer, 10);
if (endPointer == stringToConvert) { /* stringToConvert is not an integer */ }

Share this post


Link to post
Share on other sites
quote:
Original post by Way Walker
The best way using C is strtol or strtoll in stdlib.h

He''s converting in the opposite direction.

Share this post


Link to post
Share on other sites
quote:
Original post by SabreMan
quote:
Original post by Way Walker
The best way using C is strtol or strtoll in stdlib.h

He''s converting in the opposite direction.


Oh, heheh... sorry

Share this post


Link to post
Share on other sites

  • Advertisement