Making an array containing structures - C

Today I'm trying to implement a queue, but one that works with structures within arrays (I've always hated the C 'Array of Structs' terminology, as I am not trying to make that). However, when I try and do a basic initialization, I run into the compiler error as follows.

"Request for member '**' in something not a structure or union. "

Here's my code, not much as of now.

//------------------------Preprocessor Instructions. ------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#define MAX 128
#define BUFFER 120

//-------------------------Global Stuff -------------------------------------------------
int head=-1;
int tail=-1;    //Starting head and tail at -1. 

struct Entry{
    int Data;
    int Hops;   
struct Entry Queue[MAX];    //Queue made up of structs.

int visited[MAX];

//------------------------Function Definitions. -----------------------------------------
int QueuePush(struct Entry *q, int num);
int QueuePop(struct Entry *q);
int IsEmpty(struct Entry *q);

//------------------------Main. ---------------------------------------------------------
int main(void)
    int i;


        printf("Queue Data[%d] = %d \n", i, Queue[i].Data);
        printf("Queue Hops = %d \n", Queue[i].Hops);


Am I making some scary, large error in the way I'm defining the array? Or is the issue syntactical? Thanks in advance.


You should write

Queue[i].Data = 0;
Queue[i].Hops = 0;


Queue.Data[i] = 0;
Queue.Hops[i] = 0;

In you initialization while loop, you have written Queue.Data[i] instead of Queue[i].Data.

And another thing:

int i;


Here i contains random number and this loop will not work, so you should write int i = 0; or use for instead of while.

Need Your Help

iPhone:How to make an integer array and store values in Obj-C?

iphone objective-c

I want to know a simple thing, which i couldn't get it is that i want to store 10 values in an integer array dynamically and then i have to check that stored values and compared with the current va...