错误C4700:使用未初始化的局部变量“”

时间:2016-03-06 02:31:21

标签: c static

我知道这个问题无处不在,但我找不到解决方案,此时我非常沮丧。 我想要做的是创建和使用静态库。得到了我需要构建解决方案的最后一点,但我不断收到此错误。我知道代码有一些东西,也许更多,可能完全没有,但我不能在数小时和数小时后才能真正看到它。你知道,“因为树木,你无法看到森林”W / e。这是一些屏幕。

enter image description here

enter image description here

#include <iostream>
#include <conio.h>
#include "matrice.h"

void din_alocation(int n, int m){
    float **mat;
    mat = (float**)calloc(n, sizeof(float*));
    for (int i = 0; i < n; i++)
        mat[i] = (float*)calloc(m, sizeof(float));
}
void read(float **mat, int n, int m){
    for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
        printf("mat[%d][%d]= ", i, j); scanf_s("%f", &mat[i][j]);
    }
}
void write(float **mat, int n, int m){
    for (int i = 0; i < n; i++){
        printf("\n");
        for (int j = 0; j < m; j++)
            printf("%.2f  ", mat[i][j]);
    }
}

void din_realocation(float **mat, int n){
    for (int i = 0; i < n; i++)
        free(mat[i]);
    free(mat);
}

1 个答案:

答案 0 :(得分:0)

错误应该很清楚。您不会在mat函数中的任何位置初始化变量main

一个解决方案是din_alocation函数返回它分配的数据,然后执行

mat = din_alocation(x, y);
相关问题