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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Char Buffer vs CString

  • 15-06-2004 8: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