ok i was wondering if i could resize an array by taking an array pointer and copying it and new items in to an array than deleting the only array and putting the new one in it... heres my attempt
1 2 3
//i have this passing in to it, its in the main method
student *array = new student[x];
int delOne(student *k, int x)
{
int t = x-1;
student *newArray = new student[t];
cout<< "which student would you like to delete from the list" << endl;
for(int i = 0; i < x; i++)
{
cout <<i << ") " << k[i].id << endl;
}
int mp;
cin >> mp;
int z = 0;
for(int i = 0; i < x; i++)
{
if(i == mp)
{continue;}
z++;
newArray[z] = k[i];
}
delete k; //delete old array
k=newArray; //save new downsized array
return z; //return the size of the array for further use
}
frankly its not working and im wondering why?
well i noticed its probably because i don't increase the size of x but i cant seam to figure out where i should do that