static int sprintf_2_2d(char *s, int d1, int d2) { char *s2 = s; *(s2++) = '['; s2 = itoa_2(d1, s2); *(s2++) = ':'; s2 = itoa_2(d2, s2); *(s2++) = ']'; *s2 = 0; return(s2 - s); }
int main() { int a1 = -123; int a2 = 123; char s1[10]; char s2[10]; itoa_1(a1, s1); printf("%s\n", s1); itoa_1(a2, s2); printf("%s\n", s2); itoa_2(a1, s1); printf("%s\n", s1); itoa_2(a2, s2); printf("%s\n", s2); return 0; }
/* * preformatted sprintf statements which remove parsing latency */ static int sprintf_2_1d(char *s, int d) { char *s2 = s; *(s2++) = '['; *(s2++) = '0'; *(s2++) = ':'; s2 = itoa_2(d, s2); *(s2++) = ']'; *s2 = 0; return(s2 - s); }