main () { char s[MAXLEN]; printf("INT_MAX: %d\n", INT_MAX); itoa1(INT_MAX, s); printf("Buffer : %s\n", s); printf("INT_MIN: %d\n", INT_MIN); itoa1(INT_MIN, s); printf("Buffer : %s\n", s); return 0; }
int itoa1(int n, char s[], int start) { char ch = (char) abs(n % 10) + '0'; int i = (n / 10) ? itoa1(n / 10, s, start) : start; s[i] = ch; return i + 1; }
void itoa(int n, char s[]) { int start = 0; if (n < 0) { s[0] = '-'; start = 1; } itoa1(n, s, start); }
void format_lap(time_t lap_time, char* buffer) { int hundredths = (lap_time / 100) % 10; int seconds = (lap_time / 1000) % 60; int minutes = (lap_time / 60000) % 60; int hours = lap_time / 3600000; itoa2(hours, &buffer[0]); buffer[2] = ':'; itoa2(minutes, &buffer[3]); buffer[5] = ':'; itoa2(seconds, &buffer[6]); buffer[8] = '.'; itoa1(hundredths, &buffer[9]); }
int main(int argc, char const *argv[]) { itoa1(); return 0; }