how to allocate memory for struct itself, and its members
- by Jack
I have this struct:
struct foo {
char *a;
char *b;
char *c;
char *d;
};
it's possible allocate space for struct itself and its members instead of e.g,
struct foo f;
f.a = malloc();
f.b = malloc();
f.c = malloc();
f.d = malloc();
strcpy(f.a, "a");
strcpy(f.b, "b");
//..
something like this(of couse that it doesn't works):
struct foo f = malloc(sizeof(struct f));
strpcy(f.a, "a");
//etc