'C++: How to remove elements from array at given range without a vector?

I want to delete elements from an array for the given range (indexes) without using vector. For example, if the array is

arr[5] = {1, 2, 3, 4, 5}

and the lowRange is 0 and highRange is 2. So the result would be arr = {4, 5}. So far I have:

for (int i = 0; i < arrSize; i++) {
    if (i >= lowRange && i <= highRange) {
        
        arr[i] = arr[i + 1];

    }
}

But this is not working, it returns an array with mixed numbers.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source