I am getting the following errors.

../MergeSort.c:32: error: expected expression before ‘]’ token
../MergeSort.c:33: error: expected expression before ‘]’ token

void mergesortinplace (int start, int length, int array[]){
    if (length >= 2){
        mergesortinplace(0, (length/2), array[]); /*GETTING ERROR HERE*/
        mergesortinplace((length - (length/2)), length, array[]); /*AND HERE*/
    if (length >= 1){
        if (array[start] > array[length]){
            int tmp = array[start];
            array[start] = array[length];
            array[length] = tmp;

As I am relatively new to c I still don't know what most errors are so would anyone care to explain exactly what this error means and why it is occurring here. Thanks.

Recommended Answers

All 2 Replies

Line 3: that is not the way to pass an array. Omit the []. All you do is pass the name of the array, like this: mergesortinplace(0, (length/2), array);

Thanks, its these little things that are really hard to find for a new programmer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.