I have a really small problem with my insertion sort and I cannot figure it out.
my program is set up to take an unlimited amount of random values as input after the prompt my only problem is when I put my insertion sort function inside my main function and I have a small problem with the parameters. it says expected an expression. I have comments marked at the problem.
#include <iostream>
//#include <algorithm>
usingnamespace std;
int a[];
int n;
int key;
void insertionSort(int a[], int n)
{
int i, j;
for (i=1; i<=n ; i++)
{
key = a[i];
j=i-1;
while(a[j]> key&&j>=0)
{
a[j+1]=a[j];
j--;
}
if(j+1 != i){
a[j+1]=key;
}
cout<<a[j];
}
}
int main()
{
cout<<"Please enter a random series of values: ";
cin>>n;
cout<<endl;
insertionSort(a[], n);//my problem is the array a[] says expected an expression
system ("PAUSE");
return 0;
}
Thanks for the reply Lowest
your suggestion worked but it's now giving me an error saying
Error 1 error LNK2001: unresolved external symbol "int * a" (?a@@3PAHA)
Error 2 error LNK1120: 1 unresolved externals 1 1 sortAlgorithms