Re: Help with understanding this please



mdh said:

I am trying to define a struct called temp, using this code. Please be
kind in explaining with this is not working :-)

#include <stdio.h>
#include <stdlib.h>


struct t_node_n{
char *word;
int match;
struct t_node_n *left;
struct t_node_n *right;
};


struct t_node_n *temp = (struct t_node_n *) malloc(sizeof(struct
t_node_n));

Better: struct t_node_n *temp = malloc(sizeof *temp);

Cleaner, tighter, less maintenance hassle.

/* error: initializer element is not constant */

Yes. You can't call a function except from within a function.

int main {};

Hmmm. I think you've been awake far too long. Get some rest. :-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages