I keep getting this error!
int *newarr(int, int, int&); //prototype
//[Error] initializing argument 1 of 'int* newarr(int, int, int&)' [-//fpermissive]
arrayptr=newarr(arr,i,ctr); //calling from main ( arrayptr is a pointer )
//[Error] invalid conversion from 'int*' to 'int' [-fpermissive]
//this is the function
1 2 3 4 5 6 7 8 9 10 11 12 13
|
int *newarr(int arr[],int i,int &ctr)
{
int *arrayptr=new int[i*2];
for(int j=0;j<i;j++)
{
*arrayptr=arr[j];
arrayptr++;
ctr++;
}
return arrayptr;
}
|
I tried a couple of different things,I don't get whats the problem
Last edited on
your function expects an array of integers (which is a pointer) to be the first argument.
Your prototype did not match your function definition
int *newarr(int, int, int&); //prototype
int *newarr(int arr[],int i,int &ctr)
your prototype specified that an int would be the first argument, in actual usage you passed an array which is a pointer.
Last edited on