Thread: Error c2440, PLEASE, PLEASE help

  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,380
    >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