C语言三级指针用法

一、介绍
三级指针主要用于传递多个字符串到函数外面

二、程序示例

#include <stdio.h>


//鐘舵€佷笂鎶ユ帴鍙?
int status1_read(char ***node, int *subnum)
{
    
    
   const char *temp[] = {
    
    "status1", "value1", "123", "value2", "456"};
   int i;
   *subnum = 2;
   *node = (char **)malloc(3*sizeof(char *));//鐢熸垚2绾ф寚閽?
   for(i = 0; i < 3; i++)
   {
    
    
      (*node)[i] = temp[i];//鎸囧悜瀛楃涓叉暟缁?
   }
   //*node = temp;

   return 0;
}

int status1_read_test()
{
    
    
    char **strs;
    int num,i;

    status1_read( &strs, &num);
    for(i = 0; i <= num; i++)
    {
    
    
        printf("%s\n", strs[i]);
    }
    free(strs);
}

int main()
{
    
    
    status1_read_test();
    return 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u010835747/article/details/120491181
今日推荐