# ASCII to HEX convertion function?

I was wondering if anyone has a ASCII to Hex convertion functioncode snippet in C.

All responses much appreciated!

• :
: I was wondering if anyone has a ASCII to Hex convertion functioncode snippet in C.
:
: All responses much appreciated!

ASCII to Hex doesnt mean anything, so I'll assume you mean a base 10 number to base 16. If that's the case, you can just use sprintf(). If you dont know what conversion type specifier to use, go here:

http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.12.html#printf

And look at the list. Im sure you'll be able to spot the one you need.
• [b][red]This message was edited by JBaker at 2003-6-3 13:40:36[/red][/b][hr]
:
: I was wondering if anyone has a ASCII to Hex convertion functioncode snippet in C.
:
: All responses much appreciated!
:

ASCII is not a value but rather a table of values that represent a globally accepted standard character set. For example;

The upper case letter 'A' has a decimal (a 10 base numbering system) value of 65 a hexadecimal(a 16 base numbering system) value of 41, a octal (8 base numbering system) value of 101.

You can find an outstanding explanation and ASCII table here;
http://www.asciitable.com

In a nutshell;

main()
{
unsigned char Decimal_A = 65;
unsigned char Octal_A = 101;
unsigned char Ascii_A = 'A';

printf("The Decimal value of %i, represents the ASCII value: %c
",Ascii_A,Decimal_A);

printf("The Hexadecimal value of %x, represents the ASCII value: %c
",Ascii_A,Decimal_A);

printf("The Octal value of %o, represents the ASCII value: %c
",Ascii_A,Decimal_A);

return;
}

BTW, the link that Manning posted for you is the best compilation of descriptions for format specifiers that Ive ever seen. Hi-5 to Manning!

[hr]
[blue][size=4]JBaker[/size][/blue]