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. strcmp for NULL character

strcmp for NULL character

Scheduled Pinned Locked Moved C / C++ / MFC
13 Posts 5 Posters 3 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.
  • A Anu_Bala

    But in my applcaiton in default it will assign to some "BL001" not only for this CString. Whatever CString im using in this applcation all are initialized to this "BL001". Just i converted VC++6.0 to VS2008. After that only this problem arised.

    Anu

    N Offline
    N Offline
    Naveen
    wrote on last edited by
    #4

    How did you verify the content in the CString? while debugging or you tried to display the content in some message box? If the optimisation is no disabled, there is a chance that the debugger show incorrect value while debugging( check project properties->c++->optimization )

    nave [My Articles] [My Blog]

    A 1 Reply Last reply
    0
    • N Naveen

      How did you verify the content in the CString? while debugging or you tried to display the content in some message box? If the optimisation is no disabled, there is a chance that the debugger show incorrect value while debugging( check project properties->c++->optimization )

      nave [My Articles] [My Blog]

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

      My optimization setting is Disabled (/Od) While debugging while keeping cursor on this CString variable it shows "BL001" Actually BL001 is one term stored in char szModelName[10]. But why its get copied in all CString varialbes used in various classes. Even in some dialog,in edit boxes it displayed to BL001 instead of empty box.

      Anu

      N 1 Reply Last reply
      0
      • A Anu_Bala

        My optimization setting is Disabled (/Od) While debugging while keeping cursor on this CString variable it shows "BL001" Actually BL001 is one term stored in char szModelName[10]. But why its get copied in all CString varialbes used in various classes. Even in some dialog,in edit boxes it displayed to BL001 instead of empty box.

        Anu

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #6

        Thats bit strange. Some memory corruption I guess. Let me ask. Have you called CString::GetBuffer() at some place and didnt call CString::Releasebuffer()?

        nave [My Articles] [My Blog]

        A 1 Reply Last reply
        0
        • N Naveen

          Thats bit strange. Some memory corruption I guess. Let me ask. Have you called CString::GetBuffer() at some place and didnt call CString::Releasebuffer()?

          nave [My Articles] [My Blog]

          A Offline
          A Offline
          Anu_Bala
          wrote on last edited by
          #7

          When i searched for GetBuffer() in my coding,i get four or five GetBuffer() lines. But unfortunately there is no ReleaseBuffer(). But where i using GetBuffer(),that CString is not related to above mentioned CString. Im confused may it cause problem to all CString varialbles?

          Anu

          N 1 Reply Last reply
          0
          • A Anu_Bala

            Hi, In my coding i initialized null to CString.Im comoaring NULL character to that string.But it returns wrong value.See my code.

            CString ExeMonFile=_T("");
            int NoExeMonFile=1;
            if(strcmp(ExeMonFile,"")!=0)
            NoExeMonFile=0;

            By debugging the NoExeMonFile became 0. Then i found that ExeMonFile is initialized to some other text.How its possible. I declared ExeMonFile Globally. Im using VS2008.Whats the betterway to initialize CString .

            Anu

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

            You can use CString's Compare() function.

            1 Reply Last reply
            0
            • A Anu_Bala

              Hi, In my coding i initialized null to CString.Im comoaring NULL character to that string.But it returns wrong value.See my code.

              CString ExeMonFile=_T("");
              int NoExeMonFile=1;
              if(strcmp(ExeMonFile,"")!=0)
              NoExeMonFile=0;

              By debugging the NoExeMonFile became 0. Then i found that ExeMonFile is initialized to some other text.How its possible. I declared ExeMonFile Globally. Im using VS2008.Whats the betterway to initialize CString .

              Anu

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

              Anu_Bala wrote:

              CString ExeMonFile=_T(""); int NoExeMonFile=1; if(strcmp(ExeMonFile,"")!=0) NoExeMonFile=0;

              Why do you mix the _T("") literal with the "" one? :)

              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?

              A 1 Reply Last reply
              0
              • A Anu_Bala

                Hi, In my coding i initialized null to CString.Im comoaring NULL character to that string.But it returns wrong value.See my code.

                CString ExeMonFile=_T("");
                int NoExeMonFile=1;
                if(strcmp(ExeMonFile,"")!=0)
                NoExeMonFile=0;

                By debugging the NoExeMonFile became 0. Then i found that ExeMonFile is initialized to some other text.How its possible. I declared ExeMonFile Globally. Im using VS2008.Whats the betterway to initialize CString .

                Anu

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #10

                Bytes following a null byte are not compared.

                Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                1 Reply Last reply
                0
                • A Anu_Bala

                  When i searched for GetBuffer() in my coding,i get four or five GetBuffer() lines. But unfortunately there is no ReleaseBuffer(). But where i using GetBuffer(),that CString is not related to above mentioned CString. Im confused may it cause problem to all CString varialbles?

                  Anu

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #11

                  Anu_Bala wrote:

                  Im confused may it cause problem to all CString varialbles?

                  Cannot predict what all can happen if memory corruption occurs.

                  nave [My Articles] [My Blog]

                  1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    Anu_Bala wrote:

                    CString ExeMonFile=_T(""); int NoExeMonFile=1; if(strcmp(ExeMonFile,"")!=0) NoExeMonFile=0;

                    Why do you mix the _T("") literal with the "" one? :)

                    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]

                    A Offline
                    A Offline
                    Anu_Bala
                    wrote on last edited by
                    #12

                    My problem is ExeMonFile is not initialized to null, Its have someother value. In my applciation all Uninitialized CString Value have this ex:BL001 string. Even when initialized with _T(""), it doesnot get initialized.

                    Anu

                    CPalliniC 1 Reply Last reply
                    0
                    • A Anu_Bala

                      My problem is ExeMonFile is not initialized to null, Its have someother value. In my applciation all Uninitialized CString Value have this ex:BL001 string. Even when initialized with _T(""), it doesnot get initialized.

                      Anu

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

                      Anu_Bala wrote:

                      Even when initialized with _T(""), it doesnot get initialized.

                      You know that is a nonsense, doesn't you? :)

                      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
                      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