I am trying to write a program that dynamically increase the size of an array. essentially creating an array inside of an array with array a storing 100 int pointers. my code is initially having problems on line
a[count] = new int [n];
any tips or pointers as to how to get my code working correctly would be much appreciated.
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
int c[100];
for( int i = 0; i < 100; i++){
int n;
cin >> n;
a[count] = new int [n];
int *p = a[count];
c[count] = n;
for( int j = 0; j < n; j++)
p[j] = rand();
}
for ( int k = 0; k < count; k++){
int *b = a[k];
for ( int l = 0; l <= c[k]; l++){
cout << b[l] << endl;
}
}
for ( int m = 0; m <=count ; m++){
delete [] a[k];
}
delete [] a;
delete [] c;
system("PAUSE");
return 0;
}