10-23-2008 02:40 PM
The values are there, but recall that any C string is automatically terminated by a NULL character somewhere in the array. So, in the example above, if the number passed in to the function is less than 256, then 'high' will be 0, which when assigned as the first element of the array will cause the string to be truncated to an empty string.
Luis
10-23-2008 03:08 PM
10-24-2008 01:21 AM
Sorry, I replied without completely understanding the matter. :mansad:
From the posts, I doubt aml1138 does the null termination correctly.
Assume you have an array str[50].
If you put 10 characters into the array, for instance, you should set str[10] = 0, since you filled upto 9th index.
To be able to "visualize" your string, the bytes in the array must correspond to printable ASCII characters, as Mert noted.
Again, as noted, there is no conversion going on here. Just single item array manipulation.
If you want to get the string representation of the hex number, that's a different matter.
For example to display the hex number 0x1000 as a string (like in a message popup or file) you need:
Fmt (str, "0x%x[w4p0]", 4096); // [w4p0] means pad zeros to make the width of the string equal to 4
MessagePopup ("Hex", str);
The result is in the attachment.
Hope this helps.