Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. sizeof(CString)

sizeof(CString)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Frank Deo
    wrote on last edited by
    #1

    Hi, Exactly how much data can a CString contain? I have a large amount of text data to store in 1 CString object. The text is added to the CString object 1 line at a time with a \n\r after each line. The problem is, that when the data gets to a certain point, it all goes away. A small amount of text works fine. Is there a C++ class that will handle a large amount of text in 1 variable? Thanks, Frank

    K S H A 4 Replies Last reply
    0
    • F Frank Deo

      Hi, Exactly how much data can a CString contain? I have a large amount of text data to store in 1 CString object. The text is added to the CString object 1 line at a time with a \n\r after each line. The problem is, that when the data gets to a certain point, it all goes away. A small amount of text works fine. Is there a C++ class that will handle a large amount of text in 1 variable? Thanks, Frank

      K Offline
      K Offline
      kc 0
      wrote on last edited by
      #2

      Try allocating the CString from the heap. for example: CString *cs; cs = new CString("The Data"); // Do whatever delete cs; If that doesn't work you will have to alloc a char array on the heap.

      1 Reply Last reply
      0
      • F Frank Deo

        Hi, Exactly how much data can a CString contain? I have a large amount of text data to store in 1 CString object. The text is added to the CString object 1 line at a time with a \n\r after each line. The problem is, that when the data gets to a certain point, it all goes away. A small amount of text works fine. Is there a C++ class that will handle a large amount of text in 1 variable? Thanks, Frank

        S Offline
        S Offline
        Sam Hobbs
        wrote on last edited by
        #3

        First, it will probably work better if you use "\r\n" instead of "\n\r". I had trouble remembering which one to use until I realized that "\r\n" is like "RN" as in "Registered Nurse". People have asked about the maximum possible size of CString items and I have seen no answer to this question except 2,147,483,647 (2GB; INT_MAX). Since the return value of CString::GetLength is an int, it makes sense that a CString cannot be any larger than the value of an int. So in reality, a CString size is probably limited only to available memory.

        1 Reply Last reply
        0
        • F Frank Deo

          Hi, Exactly how much data can a CString contain? I have a large amount of text data to store in 1 CString object. The text is added to the CString object 1 line at a time with a \n\r after each line. The problem is, that when the data gets to a certain point, it all goes away. A small amount of text works fine. Is there a C++ class that will handle a large amount of text in 1 variable? Thanks, Frank

          H Offline
          H Offline
          HP
          wrote on last edited by
          #4

          Hi, a Suggestion for this behavior. The debugger will show you only 255 (or 256?) characters, even when CString contains more than this amount. HTH Holger Persch

          1 Reply Last reply
          0
          • F Frank Deo

            Hi, Exactly how much data can a CString contain? I have a large amount of text data to store in 1 CString object. The text is added to the CString object 1 line at a time with a \n\r after each line. The problem is, that when the data gets to a certain point, it all goes away. A small amount of text works fine. Is there a C++ class that will handle a large amount of text in 1 variable? Thanks, Frank

            A Offline
            A Offline
            aasher
            wrote on last edited by
            #5

            Why dont you use CStringList class which is a builtin linklist of CString. You can use it for storing each line in a sepetate element of the CStringlist object. You only have to call object.AddTail(data string) for each element. For more information you can see the detail in the MSDN help.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups