Cast void* to array of struct
<p>I have a vector of RGB data. </p>

<pre><code>vector&lt;int&gt; image({1,1,1, 2,2,2, 3,3,3 , 4,4,4}); 
</code></pre>

<p>I want to flip this image horizontally (about the center column). </p>

<p>to perform flip operation, I have created a function </p>

<pre><code>flip(void* image, int rows, int cols)
</code></pre>

<p>where i would like to perform flip, but keep individual triplets of RGB intact </p>

<p>So I created a</p>

<pre><code>struct color{
    char r;
    char g;
    char b;
};
</code></pre>

<p>and calling the function as </p>

<pre><code>int main(){
vector&lt;int&gt; image({1,1,1, 2,2,2, 3,3,3 , 4,4,4});
flip(&amp;image[0],rows,cols);
}
</code></pre>

<p>but casting void* to struct color[] raises compilation error. 
How can I proceed around this ? </p>