Share via


C++ int to string

Question

Saturday, October 9, 2010 2:35 PM

can you print out int with convert them to string ?

All replies (5)

Saturday, October 9, 2010 2:50 PM ✅Answered

_itoa_s or sprintf with %d. Nikita Leontiev


Saturday, October 9, 2010 3:26 PM ✅Answered

<_itoa_s http://msdn.microsoft.com/en-us/library/0we9x30h(v=VS.80).aspx\> or <printf http://msdn.microsoft.com/en-us/library/wc7014hz(VS.71).aspx\>with %d.

Or there are
 
std::ostringstream;
CString::Format();
 
Personally, I would use std::ostringstream.
 
David Wilkinson | Visual C++ MVP


Saturday, October 9, 2010 5:56 PM ✅Answered

Or, new to VC++ 2010, std::to_string/std::to_wstring.


Thursday, November 26, 2015 9:25 PM

Using Microsoft's String:
int i;

String str=i.toString();


Thursday, November 26, 2015 11:04 PM

Using Microsoft's String:
int i;

String str=i.toString();

Huh? That doesn't look like C++ to me. Are you confusing this with C++/CLI?