I have some code that looks like this:
When I run it I get the output:Code:#include <iostream> #include <windows.h> using namespace std; int Foo(LPVOID Bar) { Bar = "Hello"; cout << "Bar: " << Bar << endl; return 0; } int main() { char * Word = "bye"; Foo(&Word); cout << "Word: " << Word << endl; return 0; }
When Word should also be set to 'hello'. Can anyone tell me whats gone wrong? I'm useless when it comes to pointers, I don't see why the value of Word isn't being set to 'hello'Code:Bar: hello Word: bye![]()




Reply With Quote