Tree Tree -4 years ago 68
C Question

Why doesn't my strcut contain this member?

I wrote the following code:

#include <stdio.h>
#include <stdlib.h>

typedef struct
int month;
int day;
int hour;
int minutes;

typedef struct
int all_members;
char *country;
primaries_date date;

typedef struct node *ptr;

typedef struct node
usa_primaries up;
ptr next;

void add(ptr usa_primaries *hptr, int all_members, char *con, int month, int day, int hour, int minutes)
ptr p;
ptr q;
ptr t;
t = malloc(sizeof(Node));
printf("Cannot build list");

t->all_members = members;
t->county = con;
t->date->month = d->month;
t->date->day = d->day;
t->date->hour = d->hour;

while( (p1) )
if( p->date->month >= month || p->date->day >= day || p->date->hour >= hour || p->date->minutes >= minutes )
q = p;
p = p->next;

if(p == *hptr)
*hptr = t; /*Resetting head. Assigning to the head t*/
t->next = p;
q->next = t;
t->next = p;

int main()
ptr h;
int month, day, hour, minutes;
int all_memebers; /*Declaration of all_members*/
char *county;
char member;
printf("Please enter the day");
printf("Please enter the month");
printf("Please enter the hour");
printf("Please enter the minutes");
printf("Is this an all-member candidate? Y/N");
if(member == 'Y')
all_members = 1;
all_members = 0;
printf("Please enter the country");


return 0;

I got this error:

usa.c: In function ���add���:
usa.c:42:6: error: ���struct node��� has no member named ���all_members���
t->all_members = members;

I don't really understand why this error occurred, since all_members is declared in the structure usa_primaries, and the structure node, contains the structure usa_primaries within it.

Why was this error displayed and how can I fix it?

Answer Source

Node doesn't have an all_members. It has a usa_primaries, and that has all_members. Therefore:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download