c - 为什么我的结构变量不包含这个成员?

标签 c list structure

我写了下面的代码:

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


typedef struct 
{
    int month;
    int day;
    int hour;  
    int minutes;
}primaries_date;

typedef struct 
{
    int all_members;
    char *country;
    primaries_date date;
}usa_primaries;

typedef struct node *ptr;

typedef struct node
{
    usa_primaries up;
    ptr next;
}Node;



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));
    if(!t)
    {
         printf("Cannot build list");
         exit(0);
    }

    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; 
   }
   else
   {
       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");
   scanf("%d",&day);
   printf("Please enter the month");
   scanf("%d",&month);
   printf("Please enter the hour");
   scanf("%d",&hour);
   printf("Please enter the minutes");
   scanf("%d",&minutes);
   printf("Is this an all-member candidate? Y/N");
   scanf("%c",&member);
   if(member == 'Y')
     all_members = 1;
   else
     all_members = 0;
   printf("Please enter the country");
   scanf("%s",&county);

   add(&h,all_members,country,month,day,hour,minutes);

   return 0;
}

我遇到了这个错误:

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

我真的不明白为什么会出现这个错误,因为 all_members 是在结构 usa_primaries 中声明的,而结构节点中包含结构 usa_primaries。

为什么会显示此错误,我该如何解决?

最佳答案

节点 没有all_members。它有一个 usa_primariesthatall_members。因此:

t->up.all_members

关于c - 为什么我的结构变量不包含这个成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42481962/

相关文章:

C 预处理器测试多个宏的定义

c++ - C 的 SOLID 原则实现

python - 字典包含文本文件中的单词作为键,所有后续单词的列表作为值

android - Google Git 的 Android 源代码存储库的结构是什么?

c - 是否有必要使用数据结构对齐

c - 结构尺寸优化

c - 这是分割大文件的正确方法吗?

c++ - 在 C++ 中对某种列表进行排序的最快方法是什么?

python - 在 list2 文件中查找 list1 文件的所有匹配项,创建文件并将相关输出写入其中。 Python

C 编译器优化 - 涉及算术的宏