[RESOLVED] Frustration with pointers...
hello. I'm trying to implement 3DS models loader and found a tut to help me. And i found piece of code wich i cannot understand. Like title says it's about pointers. I think that that code is incorrect but compiler gives me no errors...
Code:
//I have these structures
typedef struct tagFACE
{
unsigned int a, b, c;
int MaterialID;
}stFace;
struct stMesh
{
...
stFace* pFace;
...
stMesh()
{
...
pFace = NULL;
...
}
};
struct stObject
{
int MeshsNum, MaterialsNum;
std::vector<stMesh> pMeshs;
std::vector<stMaterial> pMaterials;
stObject()
{
MeshsNum = MaterialsNum = 0;
}
};
//And i found this cycle
stMesh *pMesh = &(pObject->pMeshs[pObject->MeshsNum-1]);
for(int i=0; i<FacesNum; i++)
{
pMesh->pFace[Index].MaterialID = MaterialID; /*I cannot understand how this index can be okay?*/
}
Thanks in advance
Re: Frustration with pointers...
Sorry i found where pObject->pMeshs[pObject->MeshsNum-1].pFace whas assigned to new stFace [FacesNum]. I guess i should take a break. :P
Re: [RESOLVED] Frustration with pointers...
Pointer is actually an array.
Index is "i" as in
pMesh->pFace[i].MaterialID = MaterialID;
?