P
Paminu
If I have this struct:
#include <stdlib.h>
#include <stdio.h>
#define KIDS 4
typedef struct test {
int x;
int y;
} container;
I would now like to make an array containing 4 pointers to this struct. But
I would also like to allocate space for this array:
int main(void)
{
container *new[4];
new=malloc(sizeof(container *) * 4); // THIS LINE GIVES AN ERROR!
return 0;
}
Do I have to allocate space for each pointer at a time?
#include <stdlib.h>
#include <stdio.h>
#define KIDS 4
typedef struct test {
int x;
int y;
} container;
I would now like to make an array containing 4 pointers to this struct. But
I would also like to allocate space for this array:
int main(void)
{
container *new[4];
new=malloc(sizeof(container *) * 4); // THIS LINE GIVES AN ERROR!
return 0;
}
Do I have to allocate space for each pointer at a time?