C中->和.有什么区别

来源:互联网 发布:淘宝封店重开 编辑:程序博客网 时间:2024/05/01 18:44
#include <stdio.h>#include <stdlib.h>typedef struct Node{    int a;    int b;}node;int main(){    node *aa;    int b = aa.a;    node  bb;    int c = bb->a;}


 

上面的程序有两处错误;

->是指针指向其成员的运算符
.是结构体的成员运算符搜索

如:
struct A
{
   int a;
   int b;
};

A *point = malloc(sizeof(struct A));
point->a = 1;

A object;
object.a = 1;

 

 

有时间反汇编一下

原创粉丝点击