It is an integer, i_temp, who's value is 0x004F. I've forced it to a char, c_temp = (char)i_temp, who's value is 0x4F.
I created a variable, p_temp = &c_temp, pointing to the character 0x004F. I then created a long, l_temp, and did the following:
l_temp = strtol(p_temp, 0, 16);
After running this l_temp equals 0x00000000. It looks like the result is in hex. Wouldn't this give me the same problem?
How do I make the integer a string so I can step through each value in the c_temp variable and multiply it by it's column value?
I was going to convert the character to a decimal integer by the following:
char c_temp, *p_temp;
int temp;
c_temp = (char)i_temp;
p_temp = &c_temp;
for(i = 0; i == 3; i++)
On Sat, Sep 13, 2008 at 5:00 PM, DJ Delorie
<dj@xxxxxxxxxxx> wrote:
> I'm getting an integer value from a function that's in hex (0x004F). I want
> to convert it to decimal (79), actually to each character of the decimal
> value or 7 and 9, so I can then look up on an lcd table to see what values
> correspond to each character.
If your "hex" value is a string, use strtol(value,0,16) to parse
it as a hex value and return a numeric value.
Then, or if you already have a numeric ("int foo;") value, use
sprintf(buf,"%d",value) to format it as a decimal string. Then you
can pull the individual characters out of the buffer.
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user