C++ noob getting seg faults

Making a vector of lists of unsigneds in C++. I am clueless when it comes to pointers but I think I need to declare the vector as holding pointers to the lists.

It's just been a disaster. If it compiles at all, I get seg faults.

I don't know in advance how large the vector will be until I get a file to read (it should be on the first line) and I won't know how large the lists will be until i get through the file.

Any ideas on how to declare the vector of lists? I think once I get that I can figure out the rest (OK maybe not but I'll be closer). Thx.


  • Use a debugger to trace the location of the crash.

  • Never make a vector of raw pointers; use smart pointers only if you absolutely must have a vector of pointers.

  • Vectors do the memory management and resizing for you.

    vector<list<TYPE> > vecOfLists; //empty vecOfLists.push_back (some_list); //add new list onto the back

If you're using lists in place of an ordinary array, you might be better off using a vector of vectors instead.

Need Your Help

Calculating weighted average with criteria SQL

sql sql-server

I have a SQL Server table with the below structure:

CodeIgniter form submit redirects to localhost

php apache codeigniter redirect xampp

I have a CodeIgniter project with a very simple test application.