CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    Huntsville, AL
    Posts
    54

    Question LPCTSTR does NOT seem to Work

    I'm new to NET ... strictly using VC++
    VC Net on a Win2K machine


    char *p;
    CString Test = "Hello World";

    p = (LPCTSTR)m_SendText;

    The following error is identified .... I can't figure out how to fix it ...

    I have the same code written in VC6 that ported to NET that does not complain.



    test.cpp(114): error C2440: '=' : cannot convert from 'ATL::ChTraitsBase<BaseType>::PCXSTR' to 'char *'
    with
    [
    BaseType=TCHAR
    ]

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125
    It is preventing you from casting away the "const" of the pointer. This is deliberate.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Dec 2002
    Location
    Huntsville, AL
    Posts
    54
    I spend a lot of time trying to find the answer ... post the question and the the light bulb LIGHTS!!!

    solution:

    const char *p;


    Works fine.

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