How to convert from const char* to unsigned int c++

Viewed 95312

I am new in c++ programming and I have been trying to convert from const char* to unsigned int with no luck. I have a:

const char* charVar;

and i need to convert it to:

unsigned int uintVar;

How can it be done in C++?

Thanks

13 Answers

Try in this way

#include<iostream>
#include <typeinfo>             //includes typeid

using namespace std;

int main(){

char a  = '3';
int k = 3;

const char* ptr = &a;

cout << typeid(*ptr).name() << endl;                    //prints the data type c = char
cout << typeid(*ptr-'0').name() << endl;                //prints the data type i = integer

cout << *ptr-'0' << endl;

return 0;
}
Related