#Debug assertion failed

4 messages · Page 1 of 1 (latest)

wintry orbit
#

vector subscript out of range.
i get this error when running this:
it compiles but then i get errror.

#include <iostream>
#include <iomanip>
#include <array>
#include <vector>
using namespace std;

int main()
{
    vector <vector<int>> lol( 10 );

    //lol[0][0] = 1;

    for (int i = 0; i < lol.size(); ++i) {
        for (int j = 0; j < lol.size(); ++j) {
            lol[i][j] = i * j;
            cout << setw(4) << lol[i][j];
        }
        cout << endl;
    }

    return 0;
}```
runic drum
runic drum
#
int main(){
  std::vector<std::vector<int>> lol {10};
  for(size_t i {0}; i < lol.size(); ++i){
    for(size_t j {0}; j < lol.size(); ++j){
      lol[i].push_back(i * j);
      // the print statement here
    }
  }
  return 0;
}