I have a messy block of code like
result = (node*)malloc(sizeof(node));
result->fx = (char*)malloc(sizeof(char) * 2);
result->fx[0]='x'; result->fx[1]='\0';
result->gx = NULL; result->op = NULL; result->hx = NULL;
where I initialize an element of type
typedef struct node
{
char * fx; // function
struct node * gx; // left-hand side
char * op; // operator
struct node * hx; // right-hand side
} node;
Is there a shorthand way of doing that? In other words, is there a way to do like I would do in C++?
result = new node { new char [] {'x','\0'}, NULL, NULL, NULL };