#define MAXLEN 10001 int* addToArrayForm(int* A, int ASize, int K, int* returnSize){ int* arr=(int*)calloc(sizeof(int),MAXLEN); int i, pst=MAXLEN, flag=0, temp; for(i=ASize-1; i>=0 || K || flag; i--){ temp = (i>=0)?A[i] :0; arr[--pst]=(temp+K%10+flag)%10; flag=(temp+K%10+flag >= 10)?1 :0; K/=10; } *returnSize=MAXLEN-pst; return arr+pst; }