conversation of all number system in one c++ program. it is possible? i mean convert the binary to decimal, octal to hexa and soon. is possible in a one program?
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
int ns_from, ns_to;
char buffer[64];
string tmp;
int number;
cout << "Enter the number system to convert from (2..36): ";
cin >> ns_from;
cout << "Enter the number to convert: ";
cin >> tmp;
cout << "Enter the number system to covert to: ";
cin >> ns_to;
cout << endl;
number = strtol(tmp.c_str(), NULL, ns_from);
_itoa(number, buffer, ns_to);
cout << "The number converted: " << buffer << endl;
return 0;
}