>  Q&A  >  본문

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' 我应该怎么做呢?

大家讲道理大家讲道理2713일 전521

모든 응답(2)나는 대답할 것이다

  • 迷茫

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

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

    회신하다
    0
  • PHPz

    PHPz2017-04-17 11:40:40

    strcmp(argu.name,(*root)->stu.name)
    请注意->.的区别

    회신하다
    0
  • 취소회신하다