Difference between -> and . in a struct?

前端 未结 7 1985
夕颜
夕颜 2020-12-13 10:09

If I have a struct like

struct account {
   int account_number;
};

Then what\'s the difference between doing

myAccount.acco         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 10:36

    If myAccount is a pointer, use this syntax:

    myAccount->account_number;
    

    If it's not, use this one instead:

    myAccount.account_number;
    

提交回复
热议问题