Hi Guys
I am a newbie and appreciate some help PLEASE.
I am using a HC08Jm60 Micro. I want to use ltoa function. I found that you have to use the extras_stdio.h inc
which I did but I get an error ( ; missing but its not ) . I have seen that you have to re build the lib file and
no reference how to. I am sure where to go from here . All I want is to convert a long to a string.
Thanking you in Advance
Cheers
Hello,
Perhaps you need to "roll your own" function. The following code was adapted from that given in a recent thread within these forums.
// Converts signed 32-bit integer number to a decimal string.// The data is stored within 'buff', minimum length 12 bytes// (sign + 10 digits + null termination)void l_to_a( long val, char *buff){ long temp; byte i; char s = ' '; // Fill buffer with spaces for (i = 0; i < 11; i++) { *(buff + i) = ' '; } // Null termination for string data *(buff + i) = 0; if (val < 0) { val = -val; s = '-'; } // Convert binary value to decimal ASCII i = 10; do { temp = val; val /= 10; *(buff + i) = temp - (val * 10) + '0'; i--; } while (val); *(buff + i) = s; // Insert sign character}
Regards,
Mac
What compiler are you using?
Conversion functions like atoi or strtod are declared in stdlib.h . itoa and ltoa are not standard C functions and thus are not available in CW libs. CW 6.3 stdlib.h declares _itoa, but no _ltoa or ltoa.