invalid conversion from `void*' to `char*' when using malloc?

后端 未结 4 1828
野趣味
野趣味 2020-11-27 15:26

I\'m having trouble with the code below with the error on line 5:

error: invalid conversion from void* to char*

4条回答
  •  情书的邮戳
    2020-11-27 16:14

    I assume this is the line with malloc. Just cast the result then - char *foo = (char*)...

提交回复
热议问题