在C中将指针数组分配给指针矩阵的问题

时间:2019-04-19 16:29:59

标签: c

我试图将一个指针的每个值均等地分配给一个指针矩阵。但显然,它不起作用。有人知道我该怎么做吗?

void Evol_Temp(int N_bath, double Lambda, int N_cond, int N_iter, ofstream &arquivo){

        double *x01  = (double *) calloc(N_cond, sizeof(double));
        double *y01  = (double *) calloc(N_cond, sizeof(double));
        double *px01 = (double *) calloc(N_cond, sizeof(double));
        double *py01 = (double *) calloc(N_cond, sizeof(double));

    double **X   = (double **) calloc(N_bath, sizeof(double*));
    double **Y   = (double **) calloc(N_bath, sizeof(double*));
    double **Px  = (double **) calloc(N_bath, sizeof(double*));
    double **Py  = (double **) calloc(N_bath, sizeof(double*));


    for(i = 0; i < N_bath; j++){

        for(j = 0; j < N_cond; j++){

            X[i][j]  = x01[j];
            Y[i][j]  = y01[j];
            Px[i][j] = px01[j];
            Py[i][j] = py01[j];
        }
    }
}

0 个答案:

没有答案