char * convertToBase7(int num){ if (num==0) return "0"; char* s = (char*)calloc(1001,sizeof(char)); int pst=1000, flag=(num<0)?1 :0; num = abs(num); char buffer[10]={0}; while(num){ sprintf(buffer,"%d",num%7); s[--pst]=buffer[0]; num/=7; } if(flag) s[--pst]='-'; return s+pst; }