I want to convert string to integer. My string values are something like 0x000,0x0001 and etc(i.e. values are in hexadecimal format). if i used atoi() function then it will take only 0.
but i want the entire string.

e.g.
string abc = "0x0000";
i want...
int i = 0x0000;

can anyone help me to solve this problem. Reply me ASAP

#include <ios>
#include <sstream>

stringstream convert ( abc );

convert>> std::hex >> i;

hey narue,

thankx alot!!
Its working.
Once again thankx

Hey... there i had this same problem of converting a string to DWORD for passing a hex a decimal color value and was breaking my head for some time now.

this worked like a charm...

Thanks Narue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.