// Main Entry Point int main(){ int a = INT_MIN; //int a = INT_MAX; char s[255]; itoa3(a, s); printf("%d is %s\n", a, s); return 0; }
void itoa3(int n){ if(n<0){ n = -n; putchar('-'); } if(n/10) itoa3(n/10); putchar(n%10+'0'); }
void mainx(){ //char s[30]; //char t[30] = "hello\thank\n"; //char es[30]; //escape(s,t); //printf("%s\n",s); //cape(s,es); //printf("%s\n",es); //printf("%d\n",atoi("-1234x6")); // 寄存器变量 // 寄存器变量不支持地址访问 register int n = -1234; //char s[30]; //itob(n,s,8); //printf("%s\n",s); itoa3(n); //testFunction(); }
int main() { char s[max]; int n = 0; int w = 5; short w1 = 16; itoa3(n, s, w); printf("int: %*i itoa3: %s\n", w1, n, s); n = 21; itoa3(n, s, w); printf("int: %*i itoa3: %s\n", w1, n, s); n = 5234; itoa3(n, s, w); printf("int: %*i itoa3: %s\n", w1, n, s); n = 52344; itoa3(n, s, w); printf("int: %*i itoa3: %s\n", w1, n, s); n = 523440; itoa3(n, s, w); printf("int: %*i itoa3: %s\n", w1, n, s); n = -2147483647; itoa3(n, s, w); printf("int: %*i itoa3: %s\n", w1, n, s); /* largest negative int on this system is -2147483648 */ n = -2147483648; itoa3(n, s, w); printf("int: %*i itoa3: %s\n", w1, n, s); return 0; }