Hi,
I'm trying to add "Vertex" elements to a vector. However, when I try to execute the program, I have an error: Error -1073741819 (or C0000005)
What does this error mean? Can you help me to resolve it? Thanks!
Here's the code
Function with the error in bold
Header of the class:Code:#include "joint.h" #include <QDebug> Joint::Joint() {} void Joint::addVertex(Vertex &v) { vertexVector.push_back(v); } Vertex Joint::getVertex(int i) { return vertexVector[i]; } int Joint::numberVertex() { return vertexVector.size(); } void Joint::addJoint(Joint j) { nextJoint->push_back(j); }
The call to the function with the error from a class called "xml":Code:#ifndef JOINT_H #define JOINT_H #include "vector" #include "vertex.h" class Joint { public: Joint(); void addVertex(Vertex &); void addJoint(Joint); Vertex getVertex(int); int numberVertex(); private: std::vector<Vertex> vertexVector; std::vector<Joint> *nextJoint; }; #endif // JOINT_H
The function described before in xml.h:Code:bool xml::loadData(const char* fileName, std::vector<Joint> *joints) { qDebug() << "Checkpoint 2" <<endl; TiXmlDocument doc(fileName); bool loadOkay = doc.LoadFile(); qDebug() << "Checkpoint 3" <<endl; if (loadOkay) { printf("\n%s:\n", fileName); qDebug() << "Checkpoint 4" <<endl; ProcessFile(joints, &doc ); // defined later in the tutorial } else { printf("Failed to load file \"%s\"\n", fileName); } return loadOkay; } void xml::ProcessFile(std::vector<Joint> *joints, TiXmlDocument* pParent ) { char * cstr, *word; string line; size_t found; Vertex v; ifstream file; file.open ("C:/Users/Marcus/Desktop/C++/ABB_IRB1600_145-0.STL"); if (file.is_open()) { while ( file.good() ) { getline(file,line); found = line.find("vertex"); if(found != 0 && found < 1000) { line.erase(0,16); cstr = new char [line.size()+1]; strcpy (cstr, line.c_str()); word = strtok(cstr," "); v.x = atof(word); word = strtok(NULL," "); v.y = atof(word); word = strtok(NULL," "); v.z = atof(word); word = strtok(NULL," "); //ERROR HERE!!!! /**-|-|-|-|-|-|-|-|-|-|-|-|-|-**/ joints->front().addVertex(v); /**-|-|-|-|-|-|-|-|-|-|-|-|-|-**/ } } } file.close(); }
Code:void ProcessFile(std::vector<Joint> *joints, TiXmlDocument* pParent);




Reply With Quote