C++指针类型转换有关问题,求解(无法输出hello)
C++指针类型转换问题,求解(无法输出hello)
程序编译通过,运行出错,经过调试错误出现在strcpy((char*)str, "hello");这一句,请高手指教
------解决方案--------------------
程序编译通过,运行出错,经过调试错误出现在strcpy((char*)str, "hello");这一句,请高手指教
void fun(char* str)
{
str = (char*)malloc(100);
//strcpy(str, "hello");
}
int _tmain(int argc, _TCHAR* argv[])
{
void *str = NULL;
fun((char*)&str);
strcpy((char*)str, "hello");
cout << str << endl;
return 0;
}
------解决方案--------------------