C++: Converting Hexadecimal to Decimal
#include <iostream>
#include <iomanip>
#include <sstream>
int main()
{
int x, y;
std::stringstream stream;
std::cin >> x;
stream << x;
stream >> std::hex >> y;
std::cout << y;
return 0;
}
Well, the C way might be something like ...
#include <stdlib.h>
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
printf("%X", n);
exit(0);
}
Use std::hex
manipulator:
#include <iostream>
#include <iomanip>
int main()
{
int x;
std::cin >> std::hex >> x;
std::cout << x << std::endl;
return 0;
}