c - 错误 C4700 : uninitialized local variable "" used

标签 c static

我知道这个问题无处不在,但我找不到解决方案,此时我感到非常沮丧。 我想做的是创建和使用静态库。在最后一点我需要构建解决方案,但我不断收到此错误。我知道代码有一些东西,也许更多,也许完全是无稽之谈,但经过几个小时的尝试使其工作后我无法真正看到它。你知道,“只见树木,不见森林”。以下是一些屏幕。

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);
}

最佳答案

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

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

mat = din_alocation(x, y);

关于c - 错误 C4700 : uninitialized local variable "" used,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35822410/

相关文章:

C 如何使用带比较器功能的快速排序

c++ - 文件何时加载到内存中 - 用于 fread、fopen 和 fwrite 调用?

java - 最终静态与静态最终变量

sqlite - 如何防止应用程序长时间保持后静态变量变为空

c++ - 什么是静态变量?

c - 更新字符串的单个字符

c - 如何正确将RGB颜色保存到ppm文件?

Objective-C 中的 C 代码(类/框架/库)

在 C 中检查字符串数组中的字符串

java - 静态方法不能直接调用非静态方法