Here's my simplified program:
#include <iostream>
using namespace std;
int main () {
struct A {
int num;
};
struct B {
A * a;
};
struct C {
int number_of_entries;
struct B **entry_hash;
};
C *c;
int size = 5;
cout << "Entering data\n";
for (int i = 0; i < size; i++){
cout << "loop num: " << i << "\n";
c->entry_hash[i]->a->num = i*i;
c->number_of_entries++;
}
cout << "Finished entering data\n";
cout << "Getting data\n";
for (int i = 0; i < c->number_of_entries; i++){
cout << "loop num: " << i << "\n";
cout << "num: " << c->entry_hash[i]->a->num << "\n";
}
cout << "Finished getting data\n";
return 0;
}
Program output:
Entering data
loop num: 0
Segmentation fault
I'm trying to write information, then retrieve it through these data structures, but I'm clearly doing it wrong and I don't understand why.
The actual program I'm working with is more complicated (though similar core structure), and the data is already loaded for me, I'm just trying to retrieve it.