CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2000
    Location
    England
    Posts
    574

    Getting a CString into a char ...

    Hi
    How can i make my CString "A" fit into a char variable ?

    P

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899
    char* arr;

    arr = myCString.GetString();

    this converts the cstring to a char array ...
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    May 2000
    Location
    England
    Posts
    574
    Thanks again

  4. #4
    Join Date
    May 2000
    Location
    England
    Posts
    574
    Nope but you should use the .GetBuffer()
    that is what i think they ment ...


    Thanks anyway

    P

  5. #5
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Getting a CString into a char ...

    Originally posted by posty68
    How can i make my CString "A" fit into a char variable ?
    Do you want to get the complete string or only a character? For the complete string take a look at the operator 'LPCTSTR', for a character, use the 'GetAt()' function...

  6. #6
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Originally posted by NoHero
    char* arr;

    arr = myCString.GetString();

    this converts the cstring to a char array ...
    There is no such function 'GetString()' for the class 'CString'...

  7. #7
    Join Date
    Jan 2004
    Posts
    58
    FAQ

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637
    A char variable holds a single byte. You can't make a CString "fit" in a char. As asked, the question doesn't really make sense.

  9. #9
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    [I]Originally quoted by Andreas Masur
    There is no such function 'GetString()' for the class 'CString'...
    Actually, in VC.Net, CString (which is a CSimpleStringT) does have GetString function.

    TDM

  10. #10
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Originally posted by TDM
    Actually, in VC.Net, CString (which is a CSimpleStringT) does have GetString function.
    Okay...didn't think of that one...thanks for pointing out...

  11. #11
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899
    oh sry i forgot, GetString() is only available at dotNET ...

    ng
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

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