小编Pie*_*RTY的帖子

如何在C编程中释放浮动**

我刚刚编写了一个代码来释放float的多维选项卡:

void matrix_destroy(float **that)
{
        for (int y = 0; y < 3; ++y) {
            for (int x = 0; x < 3; ++x) {
                free (that[y][x]);
            }
        }
        free (that);
}
Run Code Online (Sandbox Code Playgroud)

我得到了那个我不明白的错误......:

SRC/creators_destructors.c: In function ‘matrix_destroy’: SRC/creators_destructors.c:56:10: error: incompatible type for argument 1 of ‘free’
free (that[y][x]);
      ^~~~ In file included from ./include/mylibs.h:13:0,
             from SRC/creators_destructors.c:8: /usr/include/stdlib.h:448:13: note: expected ‘void *’ but argument is of type ‘float’  extern void free (void *__ptr) __THROW;
         ^~~~
# cc1 0.01 0.00
make: *** …
Run Code Online (Sandbox Code Playgroud)

c free gcc compiler-errors

2
推荐指数
1
解决办法
331
查看次数

标签 统计

c ×1

compiler-errors ×1

free ×1

gcc ×1