Hey guys and gals, I'm have to do an assignment where I use pointers delete the second array value but every time I try to use a pointer it will give me the "[Error] invalid conversion from 'int' to 'int*' [-fpermissive]"
The function delete_second is suppose to delete the second number in the array.
The swap_First_Last is suppose to delete the first number in the array.
Are teacher made up the names and problems so that's why some of these are weird.
#include <iostream>
#include <cstring>
using namespace std;
void print(int Array1[], int n)
{
for (int i=0; i<n; i++)
{
cout << Array1[i] << endl;
}
cout << endl;
}
void delete_second( int * & list, int & size )
{
int *x=list[1];
delete x;
list++;
size--;
}
void addElement( int * & list, int & size, const int value )
{
int * newList = new int [size + 1];
for( int i = 0; i < size; i++ )
newList[ i ] = list[ i ];
newList[ size ] = value;
size++;
list = newList;
}
int* swap_First_Last(int *&Array1, int n)
{
int* newList = new int [size-1];
for(int i=0; i<size-1; i++)
newList[i] = list[i+1];
delete [] list;
size--;
}
int main()
{
int n;
cout << "Enter in how big you want your array to be (go from 2 and up for best results): ";
cin >> n;
int *Array1 = new int[n];
if(n<=0)
{
cout << "bad size" << endl;
return 0;
}
cout << endl << endl << "Enter in values for the array: \n";