integer to string and back

Feb 27, 2008 at 12:44pm
Please explain me if there is any way in MS-DOS applications to transform integer to string and string to integer.

Thank you!
Feb 27, 2008 at 7:38pm
See sprintf and sscanf in stdio.h : http://www.cplusplus.com/reference/clibrary/cstdio/
Feb 28, 2008 at 4:49am
Or in C++, use a std::stringstream

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <sstream>
#include <string>

using namespace std;

int main()
{
   stringstream ss;
   string str( "666" );
   ss << str;
   int num = 0;
   ss >> num;
   ss << ++num;
   ss >> str;

   return 0;
}
Topic archived. No new replies allowed.