我知道这个问题无处不在,但我找不到解决方案,此时我感到非常沮丧。 我想做的是创建和使用静态库。在最后一点我需要构建解决方案,但我不断收到此错误。我知道代码有一些东西,也许更多,也许完全是无稽之谈,但经过几个小时的尝试使其工作后我无法真正看到它。你知道,“只见树木,不见森林”。以下是一些屏幕。
#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);
}
最佳答案
错误应该很清楚。您无需在 main
函数中的任何位置初始化变量 mat
。
一种解决方案是让 din_alocation
函数返回它分配的数据,然后执行
mat = din_alocation(x, y);
关于c - 错误 C4700 : uninitialized local variable "" used,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35822410/