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. Advertising

  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. Advertising

  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. Advertising

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. 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:
    2,763
    CBFalconer
    Mar 31, 2008
  2. jerry

    Cstring convert to string

    jerry, May 16, 2009, in forum: C++
    Replies:
    3
    Views:
    1,918
    jerry
    May 17, 2009
  3. John Gregory
    Replies:
    0
    Views:
    314
    John Gregory
    Jul 5, 2009
  4. Alextophi
    Replies:
    8
    Views:
    584
    Alan J. Flavell
    Dec 30, 2005
  5. Bart Vandewoestyne
    Replies:
    8
    Views:
    813
    Bart Vandewoestyne
    Sep 25, 2012
Loading...

Share This Page