I have to declare an array of structures of size 16. The following code gives an error
code1.c:12:1: error: initializer element is not constant
typedef struct node
{
int tokenvalue;
struct node *next;
char *n;
} node;
node *dummy=(node *)malloc(26*sizeof(node));
Also using node dummy[26] gives segmentation fault. What should I do?
You can’t initialize objects having static storage with anything non compile-time constant. Leave it uninitialized and assign some memory to it in a function.