Howdy,
I have the following code that takes an LPVOID* variable as an argument.
The objective of this code is to set main()'s Word from 'bye' to 'Hello' using the Foo() function. Its working fine, but theres a problem.Code:#include <iostream> #include <windows.h> using namespace std; int Foo(LPVOID *Bar) { *Bar = new char[100]; *Bar = "Hello"; cout << "Bar: " << (char *)*Bar << endl; return 0; } int main() { char * Word = "bye"; Foo((LPVOID *)&Word); cout << "Word: " << Word << endl; return 0; }
Foo() is actually a function that will be loaded from a DLL. In the code above it is declared as "Foo(LPVOID * Bar)", but in the DLL it is "Foo(LPVOID Bar)".
Somehow I need to change the code for Foo so that it can take an LPVOID and change its contents. My understanding of pointers is very poor and so thats why I need help. If anyone can tell me what needs to be done or help me understand the process, I would be most grateful!