| ??? 09/19/06 10:27 Read: times |
#124540 - arggg!! Responding to: ???'s previous message |
It depends on wether your compiler is ansi complient or not but you should have one or all of the following sprintf,fprintf,itoa. which can do the job.the most usefull routine ,itoa,looks something like this:-
/*-------------------------------------------------------------------------
integer to string conversion
Written by: Bela Torok, 1999
bela.torok@kssg.ch
usage:
_ultoa(unsigned long value, char* string, int radix)
_ltoa(long value, char* string, int radix)
value -> Number to be converted
string -> Result
radix -> Base of value (e.g.: 2 for binary, 10 for decimal, 16 for hex)
---------------------------------------------------------------------------*/
#define NUMBER_OF_DIGITS 32
void _ultoa(unsigned long value, char* string, unsigned char radix)
{
unsigned char index;
char buffer[NUMBER_OF_DIGITS]; /* space for NUMBER_OF_DIGITS + '\0' */
index = NUMBER_OF_DIGITS;
do {
buffer[--index] = '0' + (value % radix);
if ( buffer[index] > '9') buffer[index] += 'A' - '9' - 1;
value /= radix;
} while (value != 0);
do {
*string++ = buffer[index++];
} while ( index < NUMBER_OF_DIGITS );
*string = 0; /* string terminator */
}
void _ltoa(long value, char* string, unsigned char radix)
{
if (value < 0 && radix == 10) {
*string++ = '-';
value = -value;
}
_ultoa(value, string, radix);
}
|
| Topic | Author | Date |
| 3 byte Hex to decmial in c | 01/01/70 00:00 | |
| arggg!! | 01/01/70 00:00 | |
| Keil | 01/01/70 00:00 | |
| itoa should do the trick | 01/01/70 00:00 | |
| join 3 byte hex value and convert to decmail | 01/01/70 00:00 | |
| you are an idiot | 01/01/70 00:00 | |
| Do you understand place value? | 01/01/70 00:00 | |
| dont waste your time | 01/01/70 00:00 | |
| Double trouble | 01/01/70 00:00 | |
| couls this be .. | 01/01/70 00:00 | |
| re: could this be | 01/01/70 00:00 | |
| Schizophrenic?! | 01/01/70 00:00 | |
| first of all ... it's DECIMAL ... | 01/01/70 00:00 | |
| Download! | 01/01/70 00:00 | |
| and get spammed to death | 01/01/70 00:00 | |
| rickeyworld | 01/01/70 00:00 | |
| It says hes radioactive | 01/01/70 00:00 | |
| rickey | 01/01/70 00:00 | |
| no restrictions to obtainning answers please | 01/01/70 00:00 | |
| yes! | 01/01/70 00:00 | |
| once more | 01/01/70 00:00 | |
| 8052.com way | 01/01/70 00:00 | |
| if we were to allow conditions ... | 01/01/70 00:00 | |
| hey | 01/01/70 00:00 | |
| angry? | 01/01/70 00:00 | |
| erik | 01/01/70 00:00 | |
bugmenot! | 01/01/70 00:00 |



