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. The Lounge
  3. CString or string.h ?

CString or string.h ?

Scheduled Pinned Locked Moved The Lounge
questionc++algorithmscollaborationperformance
8 Posts 7 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.
  • S Offline
    S Offline
    shadrach_india
    wrote on last edited by
    #1

    Hi friends I want to know yr ideas about string manipulation in VC++. I always like to use CString functions for string manipulation. I feel that it help me for fast coding and unwanted memory crashing. But my Team Leader says to use low lever string operation like using pointer, finding chars in a String, Searching chars. strcmp() and so on. He says it is fast execution. I feel what we want to do with string manipulations are already done in CString by low level ‘c’ coding .What is yr opinion . Is it right or wrong ?

    P D K A J 6 Replies Last reply
    0
    • S shadrach_india

      Hi friends I want to know yr ideas about string manipulation in VC++. I always like to use CString functions for string manipulation. I feel that it help me for fast coding and unwanted memory crashing. But my Team Leader says to use low lever string operation like using pointer, finding chars in a String, Searching chars. strcmp() and so on. He says it is fast execution. I feel what we want to do with string manipulations are already done in CString by low level ‘c’ coding .What is yr opinion . Is it right or wrong ?

      P Offline
      P Offline
      Pablo Aliskevicius
      wrote on last edited by
      #2

      If you want to stay close to the Windows API (converiting ANSI to BSTR), then CString is a good option. Also, the sprintf-like Format() function saves you a lot of headaches, shince it takes care of buffer overflow. On the other hand, if you care about portability (you don't own CString, and it might go the way VB6 went), std::string is the obvious choice. Both allow you access to constant pointers (CString::operator LPCTSTR(), std::string::c_str() ), which you can use as you would a plain old char *. If you think performance might be an issue, DON'T ASSUME, TEST. I did find quite a difference between CString and std::string when using STL containers - but that depends on implementation. In any case, never, never roll your own implementation. There are quite a few ready-made ones to choose from. I use (mostly) CString at the user interface layer, and std::basic_string at the business logic layer. Pablo_A

      1 Reply Last reply
      0
      • S shadrach_india

        Hi friends I want to know yr ideas about string manipulation in VC++. I always like to use CString functions for string manipulation. I feel that it help me for fast coding and unwanted memory crashing. But my Team Leader says to use low lever string operation like using pointer, finding chars in a String, Searching chars. strcmp() and so on. He says it is fast execution. I feel what we want to do with string manipulations are already done in CString by low level ‘c’ coding .What is yr opinion . Is it right or wrong ?

        D Offline
        D Offline
        Daniel Turini
        wrote on last edited by
        #3

        where someone says "hey! that was why it was so slow! CString comparisons are making it so slow..." If you're having performance problems with string comparisons, I'd suggest to change your algorithm so you reduce your string comparisons or even remove it. Binary search, quick sort, hash tables are some algorithms that come to my mind when we're talking about in-memory processing. If you're doing database manipulation or simple file parsing, a simple DFA would be unbeatable, as you'd exchange a lot of strcmp by a single array lookup for each character. If you're parsing complex languages, I'd suggest you to write a grammar in a parser construction toolkit, like ANTLR for C++. Probably, it'll beat anything your team leader will hand code. I don't see dead pixels anymore... Yes, even I am blogging now!

        1 Reply Last reply
        0
        • S shadrach_india

          Hi friends I want to know yr ideas about string manipulation in VC++. I always like to use CString functions for string manipulation. I feel that it help me for fast coding and unwanted memory crashing. But my Team Leader says to use low lever string operation like using pointer, finding chars in a String, Searching chars. strcmp() and so on. He says it is fast execution. I feel what we want to do with string manipulations are already done in CString by low level ‘c’ coding .What is yr opinion . Is it right or wrong ?

          K Offline
          K Offline
          Kastellanos Nikos
          wrote on last edited by
          #4

          I think you allready know the answer. Yes, your boss is clueless and you are going to spend most of your time manipulating char tables instead of doing actual work. :( life is hard.

          S 1 Reply Last reply
          0
          • K Kastellanos Nikos

            I think you allready know the answer. Yes, your boss is clueless and you are going to spend most of your time manipulating char tables instead of doing actual work. :( life is hard.

            S Offline
            S Offline
            shadrach_india
            wrote on last edited by
            #5

            :laugh:

            1 Reply Last reply
            0
            • S shadrach_india

              Hi friends I want to know yr ideas about string manipulation in VC++. I always like to use CString functions for string manipulation. I feel that it help me for fast coding and unwanted memory crashing. But my Team Leader says to use low lever string operation like using pointer, finding chars in a String, Searching chars. strcmp() and so on. He says it is fast execution. I feel what we want to do with string manipulations are already done in CString by low level ‘c’ coding .What is yr opinion . Is it right or wrong ?

              A Offline
              A Offline
              Anna Jayne Metcalfe
              wrote on last edited by
              #6

              Your Team Leader is wrong. Overusing low level string manipulation is a good way to ensure that you have lots of very subtle, hard to find bugs - potentially including buffer overruns. CString itself is pretty quick anyway if you use it correctly, and code using it or std::string can be a lot more maintainable. If he wants to spend time improving things, he should be reading something like Effective C++[^] rather than banging on about CStrings! Anna :rose: Currently working mostly on: Visual Lint :cool: Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

              1 Reply Last reply
              0
              • S shadrach_india

                Hi friends I want to know yr ideas about string manipulation in VC++. I always like to use CString functions for string manipulation. I feel that it help me for fast coding and unwanted memory crashing. But my Team Leader says to use low lever string operation like using pointer, finding chars in a String, Searching chars. strcmp() and so on. He says it is fast execution. I feel what we want to do with string manipulations are already done in CString by low level ‘c’ coding .What is yr opinion . Is it right or wrong ?

                J Offline
                J Offline
                Jain Mohit
                wrote on last edited by
                #7

                You should somehow get your TL to read this thread... (Thinking what might happen after that!!) :->

                1 Reply Last reply
                0
                • S shadrach_india

                  Hi friends I want to know yr ideas about string manipulation in VC++. I always like to use CString functions for string manipulation. I feel that it help me for fast coding and unwanted memory crashing. But my Team Leader says to use low lever string operation like using pointer, finding chars in a String, Searching chars. strcmp() and so on. He says it is fast execution. I feel what we want to do with string manipulations are already done in CString by low level ‘c’ coding .What is yr opinion . Is it right or wrong ?

                  J Offline
                  J Offline
                  Jorgen Sigvardsson
                  wrote on last edited by
                  #8

                  You should tell him that he's a lamer for using strcmp() and pointers, when there's inline assembler! (That ought to make him see the silliness in his own remarks)

                  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