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. A CString question

A CString question

Scheduled Pinned Locked Moved C / C++ / MFC
questioncareer
17 Posts 9 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.
  • C Offline
    C Offline
    color Aljechin
    wrote on last edited by
    #1

    How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:

    S C J 3 Replies Last reply
    0
    • C color Aljechin

      How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:

      S Offline
      S Offline
      si_69
      wrote on last edited by
      #2

      Aljechin How much of characters could I store in a CString? I

      A CString can hold up to MAX_INT (2 billion) characters. hope that helps Si

      stefanmihaimogaS 1 Reply Last reply
      0
      • S si_69

        Aljechin How much of characters could I store in a CString? I

        A CString can hold up to MAX_INT (2 billion) characters. hope that helps Si

        stefanmihaimogaS Offline
        stefanmihaimogaS Offline
        stefanmihaimoga
        wrote on last edited by
        #3

        si_69 wrote:

        A CString can hold up to MAX_INT (2 billion) characters.

        I think it's suports only 64KB, taking the amount of a new memory allocation. Am I wrong?

        T 1 Reply Last reply
        0
        • C color Aljechin

          How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          Even if CString is able to store so much data, I don't think it is a good idea. Why do you want to store all this data in one CString ? What do you need to do with this data ? A better solution would probably to look at the data as smaller block and deal only with a single block at one time. Just a suggestion.

          C 1 Reply Last reply
          0
          • C color Aljechin

            How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:

            J Offline
            J Offline
            James R Twine
            wrote on last edited by
            #5

            That is ~205KB of data, which is a small amount of data in today's world.    Note that if you are copying the data directly into the CString in one shot, the performance will be MUCH better than if you keep appending into the CString.    If you need to be messing around with individual pages or lines a lot, you might want to use something else like an embedded editor (a hidden edit/richedit control, for example), or your own implementation of a text-row table (and array of pointers, one for each page/line) or something like that.    Lastly, it might be worth making sure that the function HAS to take a CString - there are lots of examples of poorly-designed code that take CString parameters unnecessarily, when a simple LPCTSTR would work fine.    Peace! -=- James


            If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
            Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
            DeleteFXPFiles & CheckFavorites (Please rate this post!)

            B 1 Reply Last reply
            0
            • C Cedric Moonen

              Even if CString is able to store so much data, I don't think it is a good idea. Why do you want to store all this data in one CString ? What do you need to do with this data ? A better solution would probably to look at the data as smaller block and deal only with a single block at one time. Just a suggestion.

              C Offline
              C Offline
              color Aljechin
              wrote on last edited by
              #6

              Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:

              J C R J 4 Replies Last reply
              0
              • C color Aljechin

                Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:

                J Offline
                J Offline
                James R Twine
                wrote on last edited by
                #7

                If you are already getting that data as a LPCTSTR (or const char *) stream, there is no reason to go through the overhead of putting that data into a dynamically-allocated buffer (the CString).  If speed/performance is important, I would check to see if you can pass the data directly to the processing functions.    Peace! -=- James


                If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                DeleteFXPFiles & CheckFavorites (Please rate this post!)

                C 1 Reply Last reply
                0
                • C color Aljechin

                  Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:

                  C Offline
                  C Offline
                  Cedric Moonen
                  wrote on last edited by
                  #8

                  And how do you communicate with the microprocessor ? You receive data for example on the serial port ? I don't think this is a great idea to store everything in a CString. They are used for string manipulatino and not as data buffer (I suppose that the data you are receiving is not only characters but also 'binary' data). And why not open a file at the begining of the communication and store everything there. Or even write your own data class that will take care of the format of the data. This could be quite fast if you design it well.

                  1 Reply Last reply
                  0
                  • C color Aljechin

                    Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:

                    R Offline
                    R Offline
                    Roger Stoltz
                    wrote on last edited by
                    #9

                    Aljechin The input comes extremely fast

                    What does this mean? Compared to what? Using what medium (serial, ethernet, USB)? When I face such a problem I tend to separate the data collection from the analysis. I store the collected data in BLOBs, put them into a queue and analyze them in a separate thread. Usually the analysis is non-critical regarding time compared to data collection. Hope this helps -- Roger


                    It's supposed to be hard, otherwise anybody could do it!

                    C 1 Reply Last reply
                    0
                    • J James R Twine

                      If you are already getting that data as a LPCTSTR (or const char *) stream, there is no reason to go through the overhead of putting that data into a dynamically-allocated buffer (the CString).  If speed/performance is important, I would check to see if you can pass the data directly to the processing functions.    Peace! -=- James


                      If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                      DeleteFXPFiles & CheckFavorites (Please rate this post!)

                      C Offline
                      C Offline
                      color Aljechin
                      wrote on last edited by
                      #10

                      I did not put anything into a CString. Everything is unsigned char * here. That question just came into my mind.. So asked here. Thanks all.

                      1 Reply Last reply
                      0
                      • R Roger Stoltz

                        Aljechin The input comes extremely fast

                        What does this mean? Compared to what? Using what medium (serial, ethernet, USB)? When I face such a problem I tend to separate the data collection from the analysis. I store the collected data in BLOBs, put them into a queue and analyze them in a separate thread. Usually the analysis is non-critical regarding time compared to data collection. Hope this helps -- Roger


                        It's supposed to be hard, otherwise anybody could do it!

                        C Offline
                        C Offline
                        color Aljechin
                        wrote on last edited by
                        #11

                        Actually the program here is in Plain C with some asm stuff. But this question just came into my mind. I cannot use a CString even if I want it here. The data comes through a serial port. Actually there are two other layers after the microprocessor, from where the data comes to our program. Thanks :rose:

                        1 Reply Last reply
                        0
                        • stefanmihaimogaS stefanmihaimoga

                          si_69 wrote:

                          A CString can hold up to MAX_INT (2 billion) characters.

                          I think it's suports only 64KB, taking the amount of a new memory allocation. Am I wrong?

                          T Offline
                          T Offline
                          toxcct
                          wrote on last edited by
                          #12

                          Mihai Moga wrote:

                          Am I wrong?

                          sure you are... it accepts up to 2 GB !!! where di you get such an information ?

                          J 1 Reply Last reply
                          0
                          • T toxcct

                            Mihai Moga wrote:

                            Am I wrong?

                            sure you are... it accepts up to 2 GB !!! where di you get such an information ?

                            J Offline
                            J Offline
                            jhwurmbach
                            wrote on last edited by
                            #13

                            v2.0 wrote:

                            where di you get such an information

                            MSDN for Windows 3.1 ;P No offence meant, Mihai!


                            "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                            T 1 Reply Last reply
                            0
                            • C color Aljechin

                              Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:

                              J Offline
                              J Offline
                              jhwurmbach
                              wrote on last edited by
                              #14

                              Aljechin The input comes from a microprocessor

                              Aljechin The input comes extremely fast

                              If we are talking about currently commercially available PCs, "extremely fast" may be anything more than Gigabit-Ethernet. In our company, we have a machine tha can generate data in a pace of about half of the capacity of a off-the-shelf IDE-Disk. (Not or long, though). This is handeled in C++ on a standard PC.


                              "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                              J 1 Reply Last reply
                              0
                              • J jhwurmbach

                                Aljechin The input comes from a microprocessor

                                Aljechin The input comes extremely fast

                                If we are talking about currently commercially available PCs, "extremely fast" may be anything more than Gigabit-Ethernet. In our company, we have a machine tha can generate data in a pace of about half of the capacity of a off-the-shelf IDE-Disk. (Not or long, though). This is handeled in C++ on a standard PC.


                                "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                                J Offline
                                J Offline
                                James R Twine
                                wrote on last edited by
                                #15

                                InfiniBand - the only way to fly! :)    Peace! -=- James


                                If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                                Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                                DeleteFXPFiles & CheckFavorites (Please rate this post!)

                                1 Reply Last reply
                                0
                                • J jhwurmbach

                                  v2.0 wrote:

                                  where di you get such an information

                                  MSDN for Windows 3.1 ;P No offence meant, Mihai!


                                  "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                                  T Offline
                                  T Offline
                                  toxcct
                                  wrote on last edited by
                                  #16

                                  lol ok, i understand better :laugh:

                                  1 Reply Last reply
                                  0
                                  • J James R Twine

                                    That is ~205KB of data, which is a small amount of data in today's world.    Note that if you are copying the data directly into the CString in one shot, the performance will be MUCH better than if you keep appending into the CString.    If you need to be messing around with individual pages or lines a lot, you might want to use something else like an embedded editor (a hidden edit/richedit control, for example), or your own implementation of a text-row table (and array of pointers, one for each page/line) or something like that.    Lastly, it might be worth making sure that the function HAS to take a CString - there are lots of examples of poorly-designed code that take CString parameters unnecessarily, when a simple LPCTSTR would work fine.    Peace! -=- James


                                    If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                                    Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                                    DeleteFXPFiles & CheckFavorites (Please rate this post!)

                                    B Offline
                                    B Offline
                                    Blake Miller
                                    wrote on last edited by
                                    #17

                                    Lastly, it might be worth making sure that the function HAS to take a CString - there are lots of examples of poorly-designed code that take CString parameters unnecessarily, when a simple LPCTSTR would work fine. What really makes me twinge is when they specify a CString& - by reference! when an LPCTSTR would have been just fine :rolleyes: People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks

                                    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