2022.5.2指针进阶1

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

//编码的三种境界 1、看代码就是代码 2、看代码就是内存 3、看代码还是代码
//int main()
//{
//    /*char ch = 'q';
//    char* pc = &ch;*/
//    /*char* p = "hello";
//    *p = 'w';*/
//    //这样程序会挂掉
//    //char* ph = "hello bit";//本质上是把"hello bit"这个字符串的首字符的地址存储在了ph中
//    //printf("%c\n", *ph);
//    //printf("%s\n", ph);
//    return 0;
//}

//int main()
//{
//    char str1[] = "hello bit";
//    char str2[] = "hello bit";
//    char* str3 = "hello bit";
//    char* str4 = "hello bit";
//    if (str1 == str2)
//    {
//        printf("str1 and str2 are same\n");
//    }
//    else
//    {
//        printf("str1 and str2 are not same\n");
//    }
//    if (str3 == str4)
//    {
//        printf("str3 and str4 are same\n");
//    }
//    else
//    {
//        printf("str3 and str4 are not same\n");
//    }
//    return 0;
//}

int main()
{
    //指针数组
    //数组 - 数组中存放指针(地址)
    //int* arr[3];//存放整形指针的数组
    //int a = 10;
    //int b = 20;
    //int c = 30;
    //int* arr[3] = (&a, &b, &c);
    int a[5] = { 1,2,3,4,5 };
    int b[] = { 2,3,4,5,6 };
    int c[] = { 3,4,5,6,7 };
    int* arr[3] = {a,b,c};
    int i = 0;
    for (i = 0; i < 3; i++)
    {
        int j = 0;
        for (j = 0; j < 5; j++)
        {
            //printf("%d ", *(arr[i] + j));
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
        return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值