Could not able to solve this.. I am implementing a queue. After writing the complete code I
As @Naveen said you can't assign to a member of a struct that is in global scope. Depending on the version of C though you could do this:
struct Queue q = {0,0};
or
struct Queue q = {.front = 0, .rear = 0 };
Q.front = 0;
is not a simple initializer, it is executable code; it cannot occur outside of a function. Use a proper initializer for Q
.
struct Queue Q = {0, 0};
or with named initializer syntax (not available in all compilers, and as yet only in C):
struct Queue Q = {.front = 0, .rear = 0};
You can't initialize variable using Q.front = 0; Q.rear = 0;
in global scope. Those statements should be inside main
in your case.