Hi!
I think I'm beginning to figure these pointy things out:
Code:
int loop;
int x = 5;
int y = 2;
// create first subscript
long **group_total;
group_total = malloc (x * sizeof (long));
if (!group_total)
{
printf ("\n\nError! Not enough memory!\n\n");
}
//create second subscript
for (loop = 0; loop < x; loop++)
{
group_total[loop] = malloc (y * sizeof (long));
if (!group_total[loop])
{
printf ("\n\nError! Not enough memory!\n\n");
}
}
//free pointer
for (loop = 0; loop < x; loop++)
{
free (group_total[loop]);
}
I was just wondering:
1) Is this correct? It compiles and seems to run correctly, but there's no certainty there...
2) Is this everything? ie: Do I need to free the first subscript also?