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. Other Discussions
  3. The Weird and The Wonderful
  4. Fun With CString

Fun With CString

Scheduled Pinned Locked Moved The Weird and The Wonderful
regex
14 Posts 6 Posters 10 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.
  • L leppie

    CPallini wrote:

    That's typical of people without C background.

    I think you mean C++. ;P

    xacc.ide - now with TabsToSpaces support
    IronScheme - 1.0 alpha 4a out now (29 May 2008)

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #4

    leppie wrote:

    think you mean C++.

    Well, C is the C++'s background foundation. :-D

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    In testa che avete, signor di Ceprano?

    L 1 Reply Last reply
    0
    • R Rick York

      A while ago I inherited a project that was full of the following :

      // str1 and str2 are both fixed-length character strings

      if( CString( str1 ) == CString( str2 ) )
      {
      // strings match so do something here
      }

      That was the most annoying thing for a variety of reasons. I should mention that this was a communications-oriented project and all of the character strings had defined sizes so that as OK but apparently someone had an aversion to the strcmp function. I couldn't believe it. Even when there was an actual CString object, like from a dialog, they would cast the other argument to a CString to do the comparison. I guess they didn't know that CString has a const char * operator. :rolleyes:

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #5

      BTW Suppose CString equality operator implemented in a Java-string fashion: possibly the fun would be more. :-D

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • CPalliniC CPallini

        leppie wrote:

        think you mean C++.

        Well, C is the C++'s background foundation. :-D

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #6

        CPallini wrote:

        Well, C is the C++'s background foundation.

        But C has no types (well not like the OP has ;P ).

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        CPalliniC 1 Reply Last reply
        0
        • L leppie

          CPallini wrote:

          Well, C is the C++'s background foundation.

          But C has no types (well not like the OP has ;P ).

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 4a out now (29 May 2008)

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #7

          leppie wrote:

          But C has no types

          That's precisely my point. ;) Only with a (solid maybe) C background he would appreciate the introduced overhead. While, for instance, VB6 people (don't blame me for the cheap shot) maybe used to thinking String is a native type. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • R Rick York

            A while ago I inherited a project that was full of the following :

            // str1 and str2 are both fixed-length character strings

            if( CString( str1 ) == CString( str2 ) )
            {
            // strings match so do something here
            }

            That was the most annoying thing for a variety of reasons. I should mention that this was a communications-oriented project and all of the character strings had defined sizes so that as OK but apparently someone had an aversion to the strcmp function. I couldn't believe it. Even when there was an actual CString object, like from a dialog, they would cast the other argument to a CString to do the comparison. I guess they didn't know that CString has a const char * operator. :rolleyes:

            K Offline
            K Offline
            KarstenK
            wrote on last edited by
            #8

            Who knows what the compiler and linker will made of this statement. :rolleyes: I try hard to make parameters const so it can better be optimized. :-O

            Greetings from Germany

            1 Reply Last reply
            0
            • R Rick York

              A while ago I inherited a project that was full of the following :

              // str1 and str2 are both fixed-length character strings

              if( CString( str1 ) == CString( str2 ) )
              {
              // strings match so do something here
              }

              That was the most annoying thing for a variety of reasons. I should mention that this was a communications-oriented project and all of the character strings had defined sizes so that as OK but apparently someone had an aversion to the strcmp function. I couldn't believe it. Even when there was an actual CString object, like from a dialog, they would cast the other argument to a CString to do the comparison. I guess they didn't know that CString has a const char * operator. :rolleyes:

              S Offline
              S Offline
              steveb
              wrote on last edited by
              #9

              Nothing wrong with that statement. Creates two CString objects and do case sensitive compare with CString == operator.

              CPalliniC R 2 Replies Last reply
              0
              • S steveb

                Nothing wrong with that statement. Creates two CString objects and do case sensitive compare with CString == operator.

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #10

                steveb wrote:

                Nothing wrong with that statement

                In fact it isn't wrong. But it is unnecessary (just added overhead). :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                In testa che avete, signor di Ceprano?

                S 1 Reply Last reply
                0
                • CPalliniC CPallini

                  steveb wrote:

                  Nothing wrong with that statement

                  In fact it isn't wrong. But it is unnecessary (just added overhead). :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  S Offline
                  S Offline
                  steveb
                  wrote on last edited by
                  #11

                  if this was the production code of some server that kept on crashing while communicating with clients, the code snippet mentioned is the exact thing I would put in in place of the strcmp which in unsafe. yeah yeah there is strcmp_s, but that just come out in 2005. Code is probably older.

                  CPalliniC J 2 Replies Last reply
                  0
                  • S steveb

                    Nothing wrong with that statement. Creates two CString objects and do case sensitive compare with CString == operator.

                    R Offline
                    R Offline
                    Rick York
                    wrote on last edited by
                    #12

                    After the description I have given, you see nothing wrong with creating two objects to do a string comparison and doing this every single time that two strings need to be compared in the app ? All righty then. This was in an industrial automation system. That might give a clue as to why I consider it to be horrific. Or not.

                    1 Reply Last reply
                    0
                    • S steveb

                      if this was the production code of some server that kept on crashing while communicating with clients, the code snippet mentioned is the exact thing I would put in in place of the strcmp which in unsafe. yeah yeah there is strcmp_s, but that just come out in 2005. Code is probably older.

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #13

                      Well using temporary objects to wrap unreliable code doesn't make sense to me. I simply won't use unreliable code on a server. :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      In testa che avete, signor di Ceprano?

                      1 Reply Last reply
                      0
                      • S steveb

                        if this was the production code of some server that kept on crashing while communicating with clients, the code snippet mentioned is the exact thing I would put in in place of the strcmp which in unsafe. yeah yeah there is strcmp_s, but that just come out in 2005. Code is probably older.

                        J Offline
                        J Offline
                        Joe Woodbury
                        wrote on last edited by
                        #14

                        What, checking for null is to sophisticated for you? :)

                        Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                        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