Jump to content

Increment a numerical string: Difference between revisions

m
→‎{{header|C++}}: Used library template, fixed compiler link
m (→‎{{header|C++}}: Used library template, fixed compiler link)
Line 30:
 
=={{header|C++}}==
{{library|STL}}
'''Libraries:''' [[STL]]
// STL with string stream operators
#include <cstdlib>
Line 41:
if (oss << i) s = oss.str();
 
{{library|Boost}}
'''Libraries:''' [[Boost]]
// Boost
#include <cstdlib>
Line 51:
s = boost::lexical_cast<std::string>(i);
 
{{library|Qt}}
'''Libraries:''' [[Qt]]
// Qt
QString s = "12345";
Line 64:
 
 
{{Library|MFC}}
'''Libraries:''' [[Microsoft Foundation Classes]]
// MFC
CString s = "12345";
Line 73:
All of the above solutions only work for numbers <= INT_MAX. The following works for an (almost) arbitrary large number:
 
'''Compiler:''' [[GCCg++]] 4.0.2
 
#include <string>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.