美文网首页
C学习:03数组指针

C学习:03数组指针

作者: 放纵的卡尔 | 来源:发表于2018-12-14 00:59 被阅读0次
#include<stdio.h>
void test2();
int main() {
    char cs[2][3] = {"123","456"};
    int i=  *(cs[0]+1);
    char (*p)[3] = cs[0];//3指的是一维数组的长度
    int m = *(*cs + 1);

    printf("%c\n",i);//2
    printf("%c\n", m);//2
    printf("%c\n", (*p)[0]);//1
    printf("%c\n", *(*p+2));//3
    printf("%c\n", *(p[0]));//1
    printf("%c\n", **(p + 1));//4
    printf("%c\n", *(*(p+1)+1));//5
    printf("%p\n", cs[1]);//指针地址
    //指针数组是专门针对二维数组的指针,二维数组存储的是指向该数组的指针的地址,
    //是一个二级指针.

    system("pause");
    return 0;
}

void test2() {
    int a[2][3] = {{1, 2, 3},
                   {4, 5, 6}};
    int (*b)[3] = a;
    int (*c)[3] = a + 1;
    int *e = a[0];
    printf("%d\n", *e);
    printf("%d\n", *(*a));
}

[参考链接]https://blog.csdn.net/q302989778/article/details/80216899
[参考链接]http://www.cnblogs.com/mq0036/p/3382732.html

相关文章

网友评论

      本文标题:C学习:03数组指针

      本文链接:https://www.haomeiwen.com/subject/uhaihqtx.html