segmentation fault

I get segmentation fault with this code:

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "Class_Equipment.h"
#include "explode.h"

using namespace std;

vector<equipment> equipment_vector;


void load_equipment()
{
string line;
ifstream equipment_input ("equipment.txt");

while (equipment_input.good() )// is true if equipment_input isn't empty
{ getline(equipment_input,line);
string *this_line_array = explode (line, "\t");
equipment_vector.push_back(equipment(this_line_array[0],this_line_array[1],
this_line_array[2],this_line_array[3],this_line_array[4],this_line_array[5]));
}
equipment_input.close();
}

int main()
{

load_equipment();



}


the class equipment is very strait forward: it holds some things you can give to the class when you make it.

the explode function "explodes" a string, meaning it sets all the words witch are separated by "\t"(tab) in a array.


I hope you guys can figure it out I have been looking for hours
Almost certainly one or more of: this_line_array[0], this_line_array[2], this_line_array[3], this_line_array[4] and this_line_array[5] is NULL.

You may want to revise the interface to explode. If it parses an equipment from a string, why not make it return an equipment?
Last edited on
can you put the Class_Equipment.h and explode.h files up please? and I agree with kbw if you have 5 items in an array you might want to try to set the array to 6 if you haven't already done so.
It was indeed what kbw was thinking off, thx for the help guys!
Topic archived. No new replies allowed.