C语言day09-04指针数组

pragma mark 指针数组

pragma mark 概念

pragma mark 代码

#include <stdio.h>
int main()
{
#warning   字符串 二维数组

    /*
    char str[] = "lyh";
    char str1[] = "lys";
    char str2[] = "lyx";
    char str3[] = "lyt";

    char strs[4][20] =
    {
        "lyh",
        "lys",
        "lyx",
        "lyt"
    };
     */
    
#warning 指针数组
    char *str1 = "lyh";
    char *str2 = "lys";
    char *str3 = "lyx";
    char *str4 = "lyt";

    // 定义数组的格式 : 元素类型 数组名称[元素个数]
//    int a = 10;
//    int b = 20;
//    int nums[2] = {10, 20};
    
    char *names[4] =
    {
        "lyh",
        "lys",
        "lyx",
        "lyt"
    };
    
    for (int i = 0; i < 4 ; i++) {
        printf("names[%i] = %s\n",i,names[i]);
    }
    return 0;
}

    原文作者:liyuhong165
    原文地址: https://www.jianshu.com/p/78fcc1d5673b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞