I'm trying to make a 2d array in c++ which displays next digits of pi decimals. but a line:
table[row][element] = (int)pi[counter] - 48;
I get this error: 0xC0000005 telling me that I violated access rules while reading in a location: 0x0000000000000000
How can I solve this error? I'm beginner at C++
vector<vector<int> > table;
long int couner = 0;
const string pi = "3141592653589793238462643";
for (int row = 0; row < n; row++) {
for (int element = 0; element < n; element++) {
table[row][element] = (int)pi[counter] - 48;
counter += 1;
}
}
User contributions licensed under CC BY-SA 3.0