CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Sep 2003
    Location
    Australia
    Posts
    30

    LPVOID to char *

    I have some code that looks like this:

    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 I run it I get the output:
    Code:
    Bar: hello
    Word: bye
    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'
    Last edited by stovellp; September 30th, 2003 at 09:13 PM.
    SWEBS Web Server - http://swebs.sourceforge.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured