Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Char Buffer vs CString

Options
  • 15-06-2004 9:01am
    #1
    Registered Users 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 Posts: 4,676 ✭✭✭Gavin


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

    Gav


  • Registered Users 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 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