search

Home  >  Q&A  >  body text

C/C++怎样通过一个结构体访问另一个结构体的数据?

struct Student{
    char school[20];
    char name[20];
};
struct BstNode
{
    Student stu;
    BstNode* left;
    BstNode* right;
}; //定义二叉树
void isEqual(BstNode **root, Student argu){   //此处传入root的地址
   if(strcmp(argu->name,(*root)->stu->name)<0)
      //do something...
}

我想判断比较argu的name和当前节点下所包含的stu的name的大小,但是argu->name,(*root)->stu->name报错: base operand of '->' has non-pointer type 'Student' 我应该怎么做呢?

大家讲道理大家讲道理2803 days ago565

reply all(2)I'll reply

  • 迷茫

    迷茫2017-04-17 11:40:40

    argu.name, (**root).stu.name

    reply
    0
  • PHPz

    PHPz2017-04-17 11:40:40

    strcmp(argu.name,(*root)->stu.name)
    Please note the difference between -> and .

    reply
    0
  • Cancelreply