bai_jimmy

导航

C语言:结构体与数组

 

#include <stdio.h>
struct book{
        char title[100];
        char author[100];
        int price;
};

int arr[10] = {1,2,3,4,5,6,7,8,9,10};

int main(){
        struct book *ps1;
        struct book c = {
                "PHP最佳实践",
                "jimmy",
                67,
        };
        printf("%p\n",c);
        printf("%p\n",&c.title);
        //1 结构体指针的赋值
        ps1 = &c;
        //数组指针的赋值
        int *ps2;
        ps2 = arr;

        //结构体数组
        struct book d[10];
        struct book *ps3;
        ps3 = &d[0];

        //二维数组
        int arr2[2][4] = {1,2,3,4,5,6,7,8};
        int (*ps4)[4];
        ps4 = arr2;
        printf("%d,%d\n",*(*ps4+1),*(*(ps4+1)+2));
}

 

posted on 2015-05-01 17:17  bai_jimmy  阅读(429)  评论(0编辑  收藏  举报