0
int *merge (int *array1, int *array2){
    int iL = sizeof(array1)/sizeof(int);
    int jL = sizeof(array2)/sizeof(int);
    printf ("%d, %d\n", iL,jL);
    int *mergeList = (int*)malloc((iL + jL) *sizeof(int));
    int i=0,j=0,k=0;
    while (i < iL && j < jL){
        if (array1[i]<array2[j]){
            mergeList[k++] = array1[i++];
        }
        else{
            mergeList[k++] = array2[j++];
        }
    }
    while (i < iL){
        mergeList[k++] = array1[i++];
    }
    while (j<jL){
        mergeList[k++] = array2[j++];
    }
    return mergeList;
}

so the two lists entering the method is

list1 [6] = {2,-1,0,3,1,6};
list2 [2] = {-6,-10};

but for some reason, when they method prints out the length of each input arrays, the output: 2,2. I have been stuck with this for 2 hours...

simonc
  • 41,632
  • 12
  • 85
  • 103
FamilyMaze
  • 61
  • 5
  • You should read about pointers and arrays. Look at this question: http://stackoverflow.com/questions/492384/how-to-find-the-sizeofa-pointer-pointing-to-an-array – Ternvein Dec 12 '14 at 22:31
  • 2
    What you're computing is the size of a pointer divided by the size of an `int`. An answer of 2 would suggest that on your machine, pointers are 64-bit and `int` is 32-bit. – user3386109 Dec 12 '14 at 22:39

0 Answers0