Error 4 error C2440: 'initializing' : cannot convert from 'void *' to 'char *'

馋奶兔 提交于 2020-01-17 08:45:27

问题


I tried to compile this and got mistakes such as:

Error   4   error C2440: 'initializing' : cannot convert from 'void *' to 'char *'  

This code is taken from here. Why doesn't it work?

DWORD dwRead=0;

char *lpData = (VOID*)GlobalAlloc(GMEM_FIXED, MAX_READ),

回答1:


You appear to be compiling with a C++ compiler, so you'll need an explicit cast:

char *lpData = (char *)GlobalAlloc(GMEM_FIXED, MAX_READ);


来源:https://stackoverflow.com/questions/15105980/error4error-c2440-initializing-cannot-convert-from-void-to-char

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!