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?

Recommended Answers

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);
}
Jump to Post

All 2 Replies

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.