I making some revisions to an old program I wrote. It means having to have an array that is not initialised at the beginning. The array in question is the array of vertices using a format called CUSTOMVERTEX. Normally I can declare it like this:
CUSTOMVERTEX vertices[1000];
But not this time. I want the number the array size will become - to be found by reading data out of an external file. In this case a binary file as it happens.
Great and all as it will add alot of automation to what I'm doing. What's not great is that te memcpy call now spits the std::vector I used instead of the old style array:
std::vector<CUSTOMVERTEX> vertices;
When inputted into the buffer like this:
VOID* pVoid; // a void pointer // lock v_buffer and load the vertices into it v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, &vertices[0], sizeof(vertices)); v_buffer->Unlock();
or like this:
VOID* pVoid; // a void pointer // lock v_buffer and load the vertices into it v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, &vertices[0], vertices.size()); v_buffer->Unlock();
It generates an error. The usual send don't send screen Microsoft 'has to close' error box.
No before I go racing off trying to find another solution I'd like some advice on two things if possible thanks:
1)Can I use an std::vecotr for this?
2)If I have to use a dynamic array (not even sure what that is right now) can I use it with an auto_pointer to avoid memory leaks?
Many thanks ;o)
Chris