Thursday, July 12, 2012
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

4 comments :

Contact Form

Name

Email *

Message *

Back to Top