void*从C到CPP的赋值
我想知道为什么这段代码适用于 C 而不是 C++
void* dum;
dum = "dum";
我有 C++ 错误
In function 'int main()':
8:10: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
任何 C++ 等价物?
回答
我想知道为什么这段代码适用于 C 而不是 C++
它在 C++ 中不起作用,因为字符串文字是一个 const char 数组。
任何 C++ 等价物?
const char* dum = "dum";
- Best to use that in C too