Archived

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

JIMbond21

Plz Help

Recommended Posts

Lektrix    106
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
hellz    356
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
Lektrix    106
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