I'm tasked to create a program which dynamically allocates memory for a structure. normally we would use
x=malloc(sizeof(int)*y);
However, what do I use for a structure variable? I don't think its possible to do
struct st x = malloc(sizeof(struct));
Could someone help me out? Thanks!
My favorite:
#include <stdlib.h>
struct st *x = malloc(sizeof *x);
Note that:
x
must be a pointer