VB
(1)
NIntVal
(1)
GmbH
(1)
Geschäftsführer
(1)
Amtsgericht
(1)
Thorsten
(1)
Hamburg
(1)
Schobi
(1)
function to convert int to string
Asked By Daniel
09-Jun-08 06:29 PM
I cannot find the documentation on the function to convert integer to string.
Anyone know it off the top of his / her head?
Daniel
function to convert int to string
Asked By natha
09-Jun-08 06:49 PM
What language (C, C++, C#, VB, other) are you using? In C/C++, you
can use sprintf. I'm not a mindreader, so the more information you
provide, you can help others help you.
Nathan Mates
--
function to convert int to string
Asked By Ron Francis
09-Jun-08 07:54 PM
Assuming C/C++:
As Nathan said, sprintf( ) but to be more safe use sprintf_s( )
You can also look at _itoa_s( )
Regards,
Ron Francis
www.RonaldFrancis.com
function to convert int to string
Asked By David Wilkinson
09-Jun-08 08:21 PM
Daniel:
and std::ostringstream.
--
David Wilkinson
Visual C++ MVP
I'm in the microsoft.public.vc.language newsgroup. I mean the c/c++ language.
Asked By Daniel
09-Jun-08 09:10 PM
I am in the microsoft.public.vc.language newsgroup. I mean the c/c++
language.
function to convert int to string
Asked By Tom Serface
10-Jun-08 03:04 AM
If you use CString it is easy with something like:
CString cs;
cs.Format(_T("%d"),nIntVal);
You can also use itoa(), but it is more work.
Tom
function to convert int to string
Asked By Ulrich Eckhardt
10-Jun-08 03:54 AM
Wrong. There is no such language. If you mean C, the answer will be
different than for C++, at least because they use different ways to
represent and handle strings. If you use C#, the answer will differ even
more. Even if you use C++, the answer will be different if you use the MFC
instead of the C++ standardlibrary. Anyway, google for "convert int string
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
function to convert int to string
Asked By Giovanni Dicanio
10-Jun-08 05:47 AM
I agree with Tom.
You may define a function to wrap Tom's code (that is what I use to do):
// Converts from integer to string
inline CString ToString( int n )
{
CString s;
s.Format( _T("%d"), n );
return s;
}
And in your code you can just write:
int n;
int m;
...
CString msg;
msg = _T("N = ") + ToString( n );
msg += _T("M = ") + ToString( m );
...
Giovanni
Handy how .NET has that built into just about every object type ...
Asked By Tom Serface
10-Jun-08 10:45 AM
Handy how .NET has that built into just about every object type ... :o)
Tom
function to convert int to string
Asked By Giovanni Dicanio
10-Jun-08 12:41 PM
Yes Tom.
...But it seems that we in the C++ world like to build things by ourselves
;-)
G
function to convert int to string
Asked By Hendrik Schober
12-Jun-08 10:41 AM
Daniel schrieb:
template< typename T >
inline
std::string convert2str(const T& obj)
{
std::ostringstream oss;
oss << obj;
return oss.str();
}
Schobi