I'm trying to implement an array of lists, but have some problems with dynamic memory allocation, or I`ve not clearly enough understood pointers yet;/. Here's my code:
struct List {
List * next;
char * tab1;
char * tab2;
};
int size =4000;
List ** array= new List*[size];
void add(char * table_one, char * table_two)
{
int n=40;
for(int cc =0; cc<size; cc++)
{
array[cc]->tab1 = new char[n];
array[cc]->tab2 = new char[n];
}
...
}
Unhandled exception error occurs, when i`m trying to allocate memory for tab1 and tab2:
array[cc]->tab1 = new char[n];
array[cc]->tab2 = new char[n];
I have no idea what's wrong in these lines:( Appreciate any hints!