a昊a 2020-10-03 22:31 采纳率: 66.7%
浏览 80
已采纳

C语言指针类型不匹配问题

这是一个练习变长数组的代码先上代码

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define LEN 3
#define WID 5
void show(int n,int m,double ar[n][m]);
double * Copy(int n,int m,double ar[n][m],double br[n][m]);
int main(void)
{
    double d_Arry[LEN][WID];
    double (* d_Pointer_1)[WID];
    double d_Arry_1[LEN][WID];

    srand(time(0));

    for(int i = 0; i < LEN; i++)
    {
        for(int j = 0; j < WID; j++)
        {
            d_Arry[i][j] = (rand() % 10) * 0.1;
        }
    }

    show(LEN,WID,d_Arry);

    putchar('\n');

    d_Pointer_1 = Copy(LEN,WID,d_Arry,d_Arry_1);//第28行

    show(LEN,WID,d_Pointer_1);

    putchar('\n');

    return 0;

}

void show(int i_Len,int i_Width,double d_Arry[i_Len][i_Width])
{
    for(int i = 0; i < i_Len; i++)
    {
        for(int j = 0; j < i_Width; j++)
        {
            printf("%3.1f  ",d_Arry[i][j]);
        }
        putchar('\n');
    }
}

double * Copy(int i_Len,int i_Width,double d_Arry[i_Len][i_Width],double d_Arry_1[i_Len][i_Width])
{


        for(int i = 0; i < i_Len; i++)
    {
        for(int j = 0; j < i_Width; j++)
        {
            d_Arry_1[i][j] = d_Arry[i][j];
        }
    }

    return d_Arry_1;//第62行
}

我只是搞不懂为啥28行和62行指针类型会不匹配,求大神指点

图片说明

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-10-04 09:12
    关注
    你返回的是double *,而 d_Arry_1 是 double[]*
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题