Soldato
- Joined
- 15 Feb 2011
- Posts
- 10,234
- Location
- Slough
i currently have an array with 4 columns and a user defined number of rows set up in the following way:
*this may or may not have been stolen from the internet
in my program i need to delete a row of my choice from the array. if i absolutely have to i will use a bubble sort type method to shift all the elements down one place in the array but i'm sure there must be an easier method.
having looked around the internet a bit theres the "delete points[element]" function that works quite nicely for 1D arrays, but i have no idea how to make it work how i would like to for 2D arrays.
if i were to delete row 19 i would need what was row 20 to become row 19, what was row 21 to become row 21 and so on for a variable number of rows. i cannot have it saying that row 19 is an empty row
thanks for any help you can give me
Code:
int **points;
points = new int*[num_points];
for (int i = 0; i < num_points; i++)
{
points[i] = new int[4]; //WIDTH
}
in my program i need to delete a row of my choice from the array. if i absolutely have to i will use a bubble sort type method to shift all the elements down one place in the array but i'm sure there must be an easier method.
having looked around the internet a bit theres the "delete points[element]" function that works quite nicely for 1D arrays, but i have no idea how to make it work how i would like to for 2D arrays.
if i were to delete row 19 i would need what was row 20 to become row 19, what was row 21 to become row 21 and so on for a variable number of rows. i cannot have it saying that row 19 is an empty row
thanks for any help you can give me
