How to access the main camera image as an array in c++?


I am trying to simulate a camera moving through a scene while storing the frames. I can navigate the main camera through the scene but I don’t know how to access the image array per frame in my c++ code so I can store/record each frame. What I am basically looking for is something like this

unsigned char image_array[width*height];
memcp(, image_array, sizeof(unsigned char)widthheight);

Could anyone point me to the correct “”?

Thank you!