How to convert CString to an ASCII character string?

Discussion in 'C++' started by jt, Jul 14, 2005.

  1. jt

    jt Guest

    Looking for an example how to convert and CString to an ASCII character
    string.

    Any examples on how to do this?

    Thank you,
    jt
     
    jt, Jul 14, 2005
    #1
    1. Advertisements

  2. > Looking for an example how to convert and CString to an ASCII character
    >string.


    IIRC, CString has an automatic conversion to const char*, if that's
    what you mean by an ASCII character string. If not, ask in a microsoft
    dedicated newgroup.

    CString cs("hello");
    const char *s = cs;

    Jonathan
     
    Jonathan Mcdougall, Jul 14, 2005
    #2
    1. Advertisements

  3. jt

    upashu2 Guest

    1. Just copy CString into some ASCII character array,(using strcpy() )
    TCHAR cstr[200];
    CString str="jt";
    _tcscpy(cstr,(LPCTSTR)str); ////_tcscpy() is strcpy() when _UNICODE &
    _MBCS both not defined.

    2. look on MSDN for CString
    3. Since it is pure C++ group, to submit VC++ problems, try on codeguru
    discussion forum - http://www.codeguru.com/forum/
     
    upashu2, Jul 14, 2005
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    1
    Views:
    7,203
    Bruce Barker
    Mar 15, 2006
  2. Tomás Ó hÉilidhe

    Convert native character string to ASCII array of integers

    Tomás Ó hÉilidhe, Mar 28, 2008, in forum: C Programming
    Replies:
    56
    Views:
    3,424
    CBFalconer
    Mar 31, 2008
  3. jerry

    Cstring convert to string

    jerry, May 16, 2009, in forum: C++
    Replies:
    3
    Views:
    2,232
    jerry
    May 17, 2009
  4. smitty
    Replies:
    4
    Views:
    327
    Bernard Kenik
    Sep 9, 2008
  5. John Gregory
    Replies:
    0
    Views:
    480
    John Gregory
    Jul 5, 2009
  6. Alextophi
    Replies:
    8
    Views:
    872
    Alan J. Flavell
    Dec 30, 2005
  7. Bart Vandewoestyne
    Replies:
    8
    Views:
    1,138
    Bart Vandewoestyne
    Sep 25, 2012
  8. bruce
    Replies:
    38
    Views:
    665
    Mark Lawrence
    Nov 1, 2013
Loading...