pushing array usinng bitwise operators

Lets say I have an int array[ 5 ] = {4,3,2} and I want to put a five at the start. It would look like {5,4,3,2}. One way would be to take a one value and put it one address ahead, is there a way I can just push whole array by one index and put my 5 at top?
There is no room "one address ahead", so yes, you have to push the whole array by one index and place 5 on top

For example:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <algorithm>
int main()
{
    int array[5] = {4,3,2};

    std::copy_backward(array, array+3, array+4);
    array[0] = 5;

    for(int n: array)
        std::cout << n << ' ';
}

demo: http://coliru.stacked-crooked.com/a/5a2b0595bccc9bbf

However, your title is "using bitwise operators", what did you have in mind?
closed account (2AoiNwbp)
Hi cubbi,

How does it work?
 
for(int n: array)

Is it standard ansi c++?? never saw that
thanks

Alejandro
Last edited on
closed account (2AoiNwbp)
Found it already in the tutorials, thanks
Topic archived. No new replies allowed.