• Advertisement

Archived

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

Plz Help

This topic is 5289 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
Err... no.

If the OP meant to a char*/character array, and they are therefore using C, sprintf() should be used. If you are using C++, string stream(s) should be used. On the other hand, if you did actually mean to a char, a char is an integral type, and so you could use casts, but there would be losses in precision, and I doubt you actually meant char in the first place.

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on September 2, 2003 1:46:58 PM]

Share this post


Link to post
Share on other sites
Yea, I seriously doubt the OP wanted to cast anything. I would look into sprintf as well.

Share this post


Link to post
Share on other sites
quote:
Original post by Lektrix
Err... no.

If the OP meant to a char*/character array, and they are therefore using C, sprintf() should be used. If you are using C++, string stream(s) should be used. On the other hand, if you did actually mean to a char, a char is an integral type, and so you could use casts, but there would be losses in precision, and I doubt you actually meant char in the first place.


Hmm, you''ve got a point there actually. Never really used sprintf() for that (purely as it hasn''t come about yet, although I''m sure it will ).

Click for info. on sprintf()

--hellz

Share this post


Link to post
Share on other sites
Have a search on Google for string streams, i.e. a search term such as "C++ stringstream". Also, is there some particular reason why you are using C-style strings, as opposed to C++ strings (std::string)?

I would recommend using boost::lexical_cast. It's quite a compact function, and is nice and generic - templated basic_streamstring, and so forth.

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on September 2, 2003 5:43:16 PM]

Share this post


Link to post
Share on other sites

  • Advertisement