Increment a numerical string: Difference between revisions
Content added Content deleted
m (→{{header|C++}}: Used library template, fixed compiler link) |
|||
Line 30: | Line 30: | ||
=={{header|C++}}== |
=={{header|C++}}== |
||
{{library|STL}} |
|||
'''Libraries:''' [[STL]] |
|||
// STL with string stream operators |
// STL with string stream operators |
||
#include <cstdlib> |
#include <cstdlib> |
||
Line 41: | Line 41: | ||
if (oss << i) s = oss.str(); |
if (oss << i) s = oss.str(); |
||
{{library|Boost}} |
|||
'''Libraries:''' [[Boost]] |
|||
// Boost |
// Boost |
||
#include <cstdlib> |
#include <cstdlib> |
||
Line 51: | Line 51: | ||
s = boost::lexical_cast<std::string>(i); |
s = boost::lexical_cast<std::string>(i); |
||
{{library|Qt}} |
|||
'''Libraries:''' [[Qt]] |
|||
// Qt |
// Qt |
||
QString s = "12345"; |
QString s = "12345"; |
||
Line 64: | Line 64: | ||
{{Library|MFC}} |
|||
'''Libraries:''' [[Microsoft Foundation Classes]] |
|||
// MFC |
// MFC |
||
CString s = "12345"; |
CString s = "12345"; |
||
Line 73: | Line 73: | ||
All of the above solutions only work for numbers <= INT_MAX. The following works for an (almost) arbitrary large number: |
All of the above solutions only work for numbers <= INT_MAX. The following works for an (almost) arbitrary large number: |
||
'''Compiler:''' [[ |
'''Compiler:''' [[g++]] 4.0.2 |
||
#include <string> |
#include <string> |