I'm using Turbo C++ v3 and I want to convert a string which contains hexadecimal numbers into a decimal integer. How do I do that?

Just call sscanf() to convert the string, like this

int main()
{
   char text[] = "0x1C";
   int x = 0;
   sscanf(text,"%x", &x);
   printf("%d\n", x);
}

Wow! No words can describe how grateful I'm to you. Thanks a lot

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.