C语言:结构体与数组

 

#include 
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));
}

 

转载于:https://www.cnblogs.com/bai-jimmy/p/4470898.html

你可能感兴趣的:(c/c++,php)