lines 10-13: not needed. If you want a vector to start with a specific size then just call its resize() method
line 42: str is an empty string, so attempting to access anything beyone str[0] is an error.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I think you need to learn how to use your compiler's debugger so that you don't have to ask us to do your debugging for you. If you used your compiler's debugger you would quickly find that the problem now is at line 52.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I compiled your program with VC++ 2008 Express and it crashes bigtime. I don't know what compiler you are using but I'd suggest you get a different compiler. The file I used contain just one line that you had in comments at the top of your program -- (2344)(Arne Kristoffer)(Abc 3)
It crashes here:
for (int x = 0; x != vec.size(); x++)
{
vec[x].erase(vec[x].length()-1);
vec[x].erase(0,1);
}
If you can't take the time to use a decent compiler with a great debugger then I don't have the time to do your debugging for you any more.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
EDIT: I've tried to learn some debugging, and it appears that vectorOfInformation don't get filled with any information! It's empty after the while(getline())-loop, which should append all the lines in the textfile to it.
I use the same compiler, and that's why the program doesn't crash for you. Put a check after the open statement to see if the file was actually opened. I had that problem once and had to change the location of the file.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>But, by the way, do you know why I have to locate the file somewhere else?
The file must be in the same folder that your program is running in unless the open statement tells it otherwise. For example
ifstream in("c:\\myfolder\\temp.txt");
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343