mfd mfd - 2 years ago 138
C Question

Expected primary expression before ';' token


typedef struct PROCESS{
int priority;
int lifecycle;
int ttl;


PROCESS *waiting_queue;
waiting_queue = process1; //this is were I get the error.
waiting_queue =(PROCESS *)malloc(6*sizeof(PROCESS));
if(!waiting_queue){printf("no memory for waiting queue "); exit(0);}


I am trying to create a struct array with pointer. I am getting the error. Expected primary expression before ';' token

Answer Source

You have multiple problem, but the one causing your error is that you don't define a type PROCESS, but a structure with that name.

When you use typedef to define a structure type, the type-name comes after the structure:

typedef struct

The error you have is because you define e.g. process1 as a type, so the assignment (making a pointer point to a type) doesn't make any sense.

Another, and unrelated, problem is how you define the main function. It must be defined to return an int (even if your declaration does that implicitly, it's good to do it explicitly) and to either have void for argument or an integer and an array of pointers to char. In your case it should look like

int main(void) {
    return 0;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download