Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Char Buffer vs CString

  • 15-06-2004 09:01AM
    #1
    Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭


    Hey everyone...

    I've posted here a couple of times about some software that I am developing as Im sure some of you are aware!

    In my code I quite often have to convert a char buffer into a CString so that I can perform certain operations. However, it has occured to me that the way that I do these conversions is way too complicated and also inefficient.

    So my question is this...: Is there an easy way to convert a character buffer (which could be any size) into a CString??

    (Im using Visual C++ 6.0).

    Any suggestions would be greatly appreciated! :)


Comments

  • Registered Users, Registered Users 2 Posts: 4,660 ✭✭✭Gavin


    Without going and looking at the MSDN but does CString not have a constructor that takes a char* ?

    Gav


  • Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭gobby


    Originally posted by Verb
    Without going and looking at the MSDN but does CString not have a constructor that takes a char* ?

    Gav
    Your actually dead right there. Something that I overlooked!! Thanks a million! :D


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    CString was an implementation-specific stopgap until they had proper STL support, it's continued use should be considered a backwards-compatibility matter only.

    In new code use std::string


  • Registered Users, Registered Users 2 Posts: 1,372 ✭✭✭silverside


    horses for courses. If you are already using a lot of MFC, CString has handy formatting functions and Left,Right,Mid functions. That is a lot easier than using setw etc to try and put together a std::string.
    Arent there some potential problems with reference counting if you access the contents of a std::string as individual characters? I can't remember the exact details.


Advertisement