Answers for "deleting array in c++"

C++
1

remove element from array c++

int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};

// delete 3 (index 2)
for (int i = 2; i < 8; ++i)
    array[i] = array[i + 1]; // copy next element left
Posted by: Guest on April-04-2022
1

remove element from array c++

// remove *all* 3's, return new ending (remaining elements unspecified)
auto arrayEnd = std::remove(std::begin(array), std::end(array), 3);
Posted by: Guest on April-04-2022

Code answers related to "deleting array in c++"

Browse Popular Code Answers by Language