Try this:
main() { char *y = "The quick brown fox jumps over the lazy dog"; while
(*y!=0) { printf("%x", *y++); } printf("\n");} //;-)
Ronnie
"Alvin Koh" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
>
> Shouldn't it be: (comments removed)
>
> char* y;
> switch (y[0]) {
> case 0x002D:
> value[0] = '2';
> value[1] = 'D';
> break;
> default:
> value[0] = 'X';
> value[1] = 'X';
> break;
> }
>
> Btw, if you are converting all values from 0x00 to 0xff, your switch
> statement would be very long since you have a case test for each value. So
> you would have 256 case statements.
>
> I usually use this:
>
> char *hexdigits = "0123456789ABCDEF";
> ...
> value[0] = hexdigits[y[0] >> 4];
> value[1] = hexdigits[y[0] & 0xf];
> ...
>
> Eg, This will print the hex values of the characters in the string y.
>
> main()
> {
> char *hexdigits = "0123456789ABCDEF";
> char str[3] = "\0\0\0";;
> int i;
>
> char *y = "The quick brown fox jumps over the lazy dog";
>
> for (i = 0; i < strlen(y); i++) {
> str[0] = hexdigits[y[i] >> 4];
> str[1] = hexdigits[y[i] & 0xf];
> printf("%s ", str);
> }
> printf("\n");
> }
>
>
> Hope this helps.
>
> Rgds
> Alvin
...<message cut off>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/