In article <3c**************************@posting.google.com >,
Peter L. <pl*******@bluewin.ch> wrote:
vector< vector<string> > applications;
and then I want to write into it.
applications[0][0] = "Test";
Why do I get an segmentation fault error?
Because as far as the vector is concerned, the location applications[0][0]
doesn't exist. The vector currently has zero size, so no memory has been
allocated for actual data.
I also tried to resize the array before, but
it doesn't work.
It's hard to tell you what you did wrong, because you didn't show the code
that you tried. :-(
Someone else has already showed you how to use resize() to create the
location applications[0][0]. I'll also point out that you can set your
vector to a suitable initial size when you construct it:
vector<vector<string> > applications (numRows, vector<string>(numCols));
using suitable values for numRows and numCols. (this will make all the
rows the same size, namely numCols)
--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA