Results 1 to 6 of 6

Thread: CString vs std:string

  1. #1
    Join Date
    Jun 2011
    Posts
    56

    CString vs std:string

    I have started learning the programming languages and in that I came across some of the keywords like CString and the Std::string and too many others, thus I have some doubt on that I mean to say, I want to know about their functioning in the programmed code and the most importantly the pros and the cons of the mentioned keyword. And if suppose I have to make some decision about choosing from one of them then which one should I choose?

  2. #2
    Join Date
    May 2009
    Posts
    637

    Re: CString vs std:string

    See Cstring is the useful data type. They really make simpler a lot of operations in MFC, and generally used in string manipulation, though, there are several unusual techniques to utilize CStrings, mainly I would say It is too difficult for people coming from a pure C background. One of the very suitable features of CString is the capability to concatenate two strings.

    You can follow this example :

    Code:
    CString graycat = gray + cat;

  3. #3
    Join Date
    May 2009
    Posts
    543

    Re: CString vs std:string

    I would like to tell some of the advantages of the cstring like first of all you can simply store and supervise strings in C++ source code, after that cstring offers loading strings from its original resources, along with that offers well-situated Format Message technique as well, the major important feature include well integration with Windows APIs. Moving the instances of CString approximately is contemptible.

  4. #4
    Join Date
    May 2009
    Posts
    511

    Re: CString vs std:string

    Well, if there is a requirement of scripting convenient C++ source code, the choice among the two mentioned, should be std::string, which is the part of the C++ standard library. But apart from the portable applications, I would say I discover that the CString class is a lot additional suitable than std::string, some of the reason includes, it permit loading strings from its initial resources, then it proffer a suitable Format Message technique. So according to me you should use std::string.

  5. #5
    Join Date
    Apr 2009
    Posts
    569

    Re: CString vs std:string

    See this is the simple program definition that’s you can refer for STD::string.

    Code:
    #include <afx.h>
    #include <iostream>
    
    int main()
    {
      CString P("welcome to visual C++");
      std::cout << P.GetBuffer(0) << std::endl;
      return 0;
    }
    And other one is for cstring you can refer both of these


    Code:
    #include <atlstr.h>
    #include <iostream>
    
    int main ()
    {
    CString strtesting (_T("This is using the CString “));
     
    #ifdef UNICODE
       std::wcout << (LPCTSTR)strTesting;
    #else
       std::cout << (LPCTSTR)strTesting;
    #endif
     
    return 0;
    }

  6. #6
    Join Date
    May 2009
    Posts
    529

    Re: CString vs std:string

    I would say you can simply use CStringA as a ANSI string class in whichever code and the CStringW like a wide-character string class. And you are confused about both of the class I would suggest you that you should use the Cstring only as you can see the advantages of the class as mentioned by the above user, and off course nowadays we just make applications in the Windows API only thus I would say this would be well suitable

Similar Threads

  1. String manipulation in c
    By BoanHed in forum Software Development
    Replies: 3
    Last Post: 02-12-2009, 01:07 PM
  2. How to Manipulate String using PHP String Functions
    By ComPaCt in forum Software Development
    Replies: 3
    Last Post: 21-09-2009, 09:07 AM
  3. How to convert CString to CTime
    By Heather5 in forum Software Development
    Replies: 3
    Last Post: 03-09-2009, 09:13 PM
  4. vb.net multiline string
    By CAITLIN in forum Software Development
    Replies: 3
    Last Post: 13-07-2009, 12:51 PM
  5. PHP: array to string?
    By Diwakar_12 in forum Software Development
    Replies: 4
    Last Post: 13-04-2009, 02:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,630,663.94002 seconds with 17 queries