P504 指针和结构体

 

 

#include<cstdio>
struct person {
    char *name;
    int age;
};
int main(){
    struct person first;
    struct person *ptr;
     
    first.age=21;
    first.name="Zhang San";
    ptr=&first;
     
    printf("%d\n",first.age);
    printf("%d\n",(*ptr).age);
    printf("%d\n",ptr->age);
    
    return 0;
}

  

posted @ 2016-09-07 20:41  codeisking  阅读(363)  评论(0)    收藏  举报