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. Problem with != operator of CString

Problem with != operator of CString

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 3 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.
  • V Offline
    V Offline
    vijith squadz
    wrote on last edited by
    #1

    The following is the code fragment which I used in my application, CStringb csFilePath = _T("C:\\MyFolder\\"); if(csFilePath != "\\") { DWORD dwError = GetLastError(); } And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008. But in VC6.0, there is no such problem, the error code i am getting is 0.The application is with UNICODE supported. Please help me to find out the cause of this problem. :(

    Thanks & Regards VIJITH VIJAYAN

    CPalliniC D 2 Replies Last reply
    0
    • V vijith squadz

      The following is the code fragment which I used in my application, CStringb csFilePath = _T("C:\\MyFolder\\"); if(csFilePath != "\\") { DWORD dwError = GetLastError(); } And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008. But in VC6.0, there is no such problem, the error code i am getting is 0.The application is with UNICODE supported. Please help me to find out the cause of this problem. :(

      Thanks & Regards VIJITH VIJAYAN

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

      VIJITH VIJAYAN wrote:

      if(csFilePath != "\\")

      this should probably be

      if(csFilePath != _T("\\"))

      :)

      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?

      V 1 Reply Last reply
      0
      • CPalliniC CPallini

        VIJITH VIJAYAN wrote:

        if(csFilePath != "\\")

        this should probably be

        if(csFilePath != _T("\\"))

        :)

        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]

        V Offline
        V Offline
        vijith squadz
        wrote on last edited by
        #3

        Thanks for the quick response .But at the compilation time this code didnt shown any errors or warnings . Do have any idea ,why it had happened like this ?

        Thanks & Regards VIJITH VIJAYAN

        CPalliniC 1 Reply Last reply
        0
        • V vijith squadz

          Thanks for the quick response .But at the compilation time this code didnt shown any errors or warnings . Do have any idea ,why it had happened like this ?

          Thanks & Regards VIJITH VIJAYAN

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

          Because the CStringT == operator is overloaded to handle PCYSTR.

          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
          • V vijith squadz

            The following is the code fragment which I used in my application, CStringb csFilePath = _T("C:\\MyFolder\\"); if(csFilePath != "\\") { DWORD dwError = GetLastError(); } And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008. But in VC6.0, there is no such problem, the error code i am getting is 0.The application is with UNICODE supported. Please help me to find out the cause of this problem. :(

            Thanks & Regards VIJITH VIJAYAN

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            VIJITH VIJAYAN wrote:

            And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008.

            Possibly because that's the last value that was set (with SetLastError()). In other words:

            SomeWindowsFunctionThatFailsWithCode122();
            CString csFilePath = _T("C:\\MyFolder\\");
            if (csFilePath != _T("\\"))
            {
            DWORD dwError = GetLastError();
            }

            If nothing calls SetLastError(0), then its internal value will stay 122.

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            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