Original Post
My mesh class stores the names of loaded textures, and searches against those before loading one, to avoid loading duplicates. The texture names are stored as:
Mesh.at(y).texturename.at(y)
After determining if there is a match (or not) and loading the texture (or not), the name of the texture is added using push_back:
Meshes[MeshIndex].texturename.push_back(strTexture);
strTexture is pulled from the model header with an fread, and put into char strTexture[256] with strcpy. I'm doing the same thing with Meshes[x].name[y], which contains the name of the object (rather than the texture).
The problem is that Meshes[x].texturename[y] always returns the current value of strTexture. Meshes[x].name[y] works fine. I know this must be some pointer problem, but I don't know what. Doing this works:
char *strTemp=new char[256];
strcpy(strTemp,strTexture);
Meshes[MeshIndex].texturename.push_back(strTemp);
My impression (being fairly new to C++) is that this isn't a good way to handle memory, but it does in fact work.
Question: Can anybody explain to me what's going on here? I want to understand this.
[edited by - Brother Erryn on February 19, 2003 10:57:43 PM]