faqts : Computers : Programming

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

72 of 158 people (46%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

in C++ language . How to convert number of decimal to hexadecimal number

Jul 1st, 2004 03:26
Viet Commando, tcneoh,


Of course, a number of hexadecimal must be stored in a string. Thus you 
can think about the problem convert a number to a string!
For this, use the function itoa() or function ltoa()

char *itoa( int value, char *string, int radix );
char *ltoa( long value, char *string, int radix );

Parametre:
value  : Number to be converted
string : String result
radix  : Base of value; must be in the range 2 – 36

Therefore, you should use: itoa(245621, buffer, 16) to convert the 
number 245621 to hexadecimal