Reputation: 99
so i'm working on a piece of code that should use a table of pointers to structures; here you have that structure type
#define liczbafunkcji 5
#define wielkosclasu 0
typedef struct drzewo typ;
struct drzewo {
typ *right;
typ *left;
typ *up;
char znak;
unsigned int instrukcje;
unsigned int opcje;
float value;
};
typ * t[wielkosclasu][rozmiar];
and here you have an assigning function
void przydziel(void)
{
int i,g;
for(i=0;i<wielkosclasu;i++)
{
for(g=0;g<rozmiar;i++)
{
t[i][g]=(typ*)malloc(sizeof(typ));
}
}
}
So when i'm doing something like that (*t[numerdrzewa][0]).up=NULL; it goes with " SIGSEGV, Segmentation fault." (checked with gdb) in that line, and i'm not sure what is wrong.
Upvotes: 0
Views: 204
Reputation: 15278
wielkosclasu
is 0
, so the array is empty and t[numerdrzewa][0]
would always be outside the array. Also, your function does nothing.
Upvotes: 1