Beginner issues with insertion sort using an array

I am making a rookie mistake but I just can't seem to figure out what I am doing wrong. The compiler issue is regarding when I call the insertion sort function in main and am passing in the array.  I know you pass in the array and its size separately but I'm doing something wrong and would love to know if you can help me finish this mini test program so it compiles successfully. i am trying to learn about sorting algorithms. Thanks

#include <iostream>

using namespace std;

void insertion_sort(int x[],int length)
{
    int key,i;
    for(int j=1; j<length; j++)
    {
        key=x[j];
        i=j-1;
        while(x[i]>key && i>=0)
        {
            x[i+1]=x[i];
            i--;
        }
        x[i+1]=key;
    }
}

int main()
{
    int a[6] = {5,2,4,6,1,3};
    int arraySize = sizeof(a)/sizeof(a[0]);
    cout << arraySize;

    cout << insertion_sort(a, arraySize);
    return 0;
}

Open in new window

Mark_CoAsked:
Who is Participating?
 
momi_sabagConnect With a Mentor Commented:
you did not specify what the error is
but maybe it is because you try to cout a function that returns void?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.