Created
July 28, 2018 21:55
-
-
Save GavukaAlexandr/65f5817e84b0774fe34b707c6c6c087c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define NUMBER_OF_DIGITS 16 /* space for NUMBER_OF_DIGITS + '\0' */ | |
void uitoa(unsigned int value, char* string, int radix) | |
{ | |
unsigned char index, i; | |
index = NUMBER_OF_DIGITS; | |
i = 0; | |
do { | |
string[--index] = '0' + (value % radix); | |
if ( string[index] > '9') string[index] += 'A' - ':'; /* continue with A, B,.. */ | |
value /= radix; | |
} while (value != 0); | |
do { | |
string[i++] = string[index++]; | |
} while ( index < NUMBER_OF_DIGITS ); | |
string[i] = 0; /* string terminator */ | |
} | |
void itoa(int value, char* string, int radix) | |
{ | |
if (value < 0 && radix == 10) { | |
*string++ = '-'; | |
uitoa(-value, string, radix); | |
} | |
else { | |
uitoa(value, string, radix); | |
} | |
} | |
int main() | |
{ | |
char TxBuffer1[5] ="1 123"; | |
// printf(TxBuffer1); | |
char* command; | |
for(int i = 0; i < sizeof(TxBuffer1); i++) | |
{ | |
itoa (i, command, 10); | |
printf(command); | |
// if (i == 0) { | |
// printf(TxBuffer1[i+1]); | |
// command = TxBuffer1[i+1]; | |
// } | |
} | |
// printf(command); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment