4/11/2018
Posted by 
C Program To Convert From Hexadecimal To Decimal Rating: 4,8/5 7814votes

C Program To Convert Hexadecimal To Decimal using For and While Loop. Conversion of Hexadecimal Number to Decimal Value in C Programming. Write a c Program to convert decimal to Hexadecimal number Decimal to hexadecimal conversion algorithm Suggested Reading Hexadecimal system.

C Convert Hex To Decimal

As if often happens, your question suffers from a serious terminological error/ambiguity. In common speech it usually doesn't matter, but in the context of this specific problem it is critically important.

You see, there's no such thing as 'hex value' and 'decimal value' (or 'hex number' and 'decimal number'). 'Hex' and 'decimal' are properties of representations of values. Meanwhile, values (or numbers) by themselves have no representation, so they can't be 'hex' or 'decimal'. For example, 0xF and 15 in C syntax are two different representations of the same number.

I would guess that your question, the way it is stated, suggests that you need to convert ASCII hex representation of a value (i.e. A string) into a ASCII decimal representation of a value (another string). One way to do that is to use an integer representation as an intermediate one: first, convert ASCII hex representation to an integer of sufficient size (using functions from strto.

Group, like strtol), then convert the integer into the ASCII decimal representation (using sprintf). If that's not what you need to do, then you have to clarify your question, since it is impossible to figure it out from the way your question is formulated. @Eric Why is a code solution that works getting voted down? Sure, it's ugly and might not be the fastest way to do it, but it's more instructive that saying 'strtol' or 'sscanf'. Download Eyes On The Prize.