Differences between version 10 and previous revision of ConvertingAnIntegerToaStringInCpp.
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 10 | Last edited on Monday, May 15, 2006 1:13:37 pm | by CraigBox | Revert |
Older page: | version 9 | Last edited on Monday, May 15, 2006 1:13:17 pm | by CraigBox | Revert |
@@ -9,8 +9,9 @@
char s[[256];
snprintf(s,sizeof(s),"%i",i);
return strdup(s);
}
+</verbatim>
!!Method Two: use a stringstream
<verbatim>
#include <sstream>
@@ -20,8 +21,9 @@
std::ostringstream buffer;
buffer << i;
return buffer.str();
}
+</verbatim>
or:
!!Method Three: Anything to string