Write a program to convert hexadecimal string to decimal number
The solution:-#include <iostream> using namespace std; int main() { char input[] = "64"; int val = 0; char* ptr = input; while ( *ptr != '' ) { val = val * 16 + *ptr - '0'; ptr++; } cout << val << endl; return 0; }Output:-
100
0 comments:
Post a Comment