Error c2440, PLEASE, PLEASE help

This is a discussion on Error c2440, PLEASE, PLEASE help within the Windows Programming forums, part of the Platform Specific Boards category; Hi, i'm trying to make a text editor, one of my functions should allow the user to open a file, ...

  1. #1
    Unregistered
    Guest

    Error c2440, PLEASE, PLEASE help

    Hi, i'm trying to make a text editor, one of my functions should allow the user to open a file, i'm geting a a real nasty error in it......

    This is the section that causes the problem....
    //
    //
    LPSTR pszFileText;

    pszFileText = GlobalAlloc(GPTR, dwFileSize + 1); //THE ACTUAL
    //LINE Where the error is
    //
    //

    The variables that have been used as parameters in the GlobalAlloc function, are fine, they've been setup and stuff else where.......

    The error i'm getting is......
    //
    error C2440: '=' : cannot convert from 'void *' to 'char *'
    Conversion from 'void*' to pointer to non-'void' requires an explicit cast
    //
    Can anyone please please help, i would owe you my life.

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >Conversion from 'void*' to pointer to non-'void' requires an
    >explicit cast

    So you need to cast explicitly. I guess it has to look like this:

    pszFileText = (char *) GlobalAlloc(GPTR, dwFileSize + 1);

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21