c - 警告 C4047 : '=' : 'char' differs in levels of indirection from 'char *'

标签 c visual-c++ c99

下面显示的代码有什么问题。

char filter[2] = {'\0'};
*filter = (char *)calloc((unsigned int)buf.st_size + 1, sizeof(unsigned char));

据我了解,改变数组位置没有问题吧?为什么我问这个是因为警告,

Warning 1   warning C4047: '=' : 'char' differs in levels of indirection from 'char *'

有什么想法吗?

明白了,把代码改成。谢谢@ouah

char *filter = {'\0'};
filter = (char *)calloc((unsigned int)buf.st_size + 1, sizeof(unsigned char));

最佳答案

*filter 是一个 char,您正在为其分配一个 char * 值。

关于c - 警告 C4047 : '=' : 'char' differs in levels of indirection from 'char *' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15730984/

相关文章:

c - 如何将 SQLite 数据库中的数据显示到 GTK TreeView 中?

c++ - 程序已退出,代码为 -2147483645

c - 在 C99 中空白初始化结构数组

c - C99 是否保证数组是连续的?

C : How to make the size of an array dynamic?

c - IF 语句不能正常工作

c - gtk_widget_show_all(窗口);等待函数返回值时不起作用

检查输入是否为 C 中的整数

visual-c++ - "function already has a body"

c++ - 如果在 C++ 中内联一个调用 self 的函数会发生什么