I'm trying to write a OBJMesh loader at the moment in DirectX and I came across a problem with a section of my code:
unsigned int vertexCount = vertexData.size();
VERTEX* vertices = new VERTEX[vertexCount];
std::copy(vertexData.begin(), vertexData.end(), vertices);
The vertexData
in the std::copy
is a vector<VERTEX>
and I'm trying to copy the data in vertexData to my newly created vertices array.
when I load in my objmesh file, I have checked there are 2841 vertices which is correct and I've stored it to vertexCount (I've checked it by doing a std::cout << vertexCount
).
However, the real problem is that when I check the data and size of the array by entering std::cout << vertices[3000].x
it prints out something without triggering the index out of bound error.
Knowing I've created the vertices array with a size of 2841, the compiler should stop and display a error should it not? What exactly is the problem and why is it behaving like this??
Please help
EDIT: using Visual Studio 2010 Windows 7 64bit