#include
#include
struct NODE {
char* name;
int val;
struct NODE* next;
};
typedef struct NODE Node;
Node *head, *tail;
he
The problem is that you're trying to call malloc
when you aren't executing inside of a function. If you wrap that inside a main
function, for example:
int main(int argc, char **argv)
{
Node *head, *tail;
head = (Node*) malloc( sizeof( Node ) );
/* ... do other things ... */
return 0;
}
… it works just fine. GCC's error is a little cryptic, but the problem is basically that you're trying to initialize a variable with something that isn't a constant, which is impossible outside of a function.