#include <stdio.h> #include <stdlib.h> char *itos(int num,char* str); int main() { int t; char s[8]={0}; scanf("%d",&t); itos(t,s); printf("%s",s); return 0; } char *itos(int num,char* str) { int i,j; char tmp[8]={0}; for(i=0;i<9;i++) { str[i] = num%10 + '0'; num = num/10; if(num == 0) break; } for(j=0;i>=0;i--) //倒序放入str中 str[j++] = tmp[i]; str[j] = '\0'; return str; }