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. Strange problem with errno modification while using sprintf call.

Strange problem with errno modification while using sprintf call.

Scheduled Pinned Locked Moved C / C++ / MFC
helpvisual-studiodebuggingcsharpannouncement
3 Posts 1 Posters 1 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.
  • G Offline
    G Offline
    Gajendra Sharma
    wrote on last edited by
    #1

    Hello, I am facing a strange problem in my c Windows application sigle-threaded, using VS2008 compiler. errno is used after system calls to identfiy if any error occured. I have placed checks in my code at various places to know if any exception has occured during a flow. In one of the function, At the beginning of a code block I check for errno occured in previous code block, if errno is zero, the normal flow continues. If errno is non-zero, nothing is done and the function returns with errno. Now, i found out a strange issue, errno that is initialized to 0 at the start of the function, changes its value to 9 after doing a sprintf call. sprintf call is successfull though. Another strange thing about it is that this happens only when the exe is run as service on Windows Vista. If the same exe is run from Visual Studio debugger, this behavior doesn't happen when exe runs from VS directly in either release or debug mode. I can not comprehend the behavior, any help will be appreciated. Thanks. Gajendra

    Gajendra

    G 1 Reply Last reply
    0
    • G Gajendra Sharma

      Hello, I am facing a strange problem in my c Windows application sigle-threaded, using VS2008 compiler. errno is used after system calls to identfiy if any error occured. I have placed checks in my code at various places to know if any exception has occured during a flow. In one of the function, At the beginning of a code block I check for errno occured in previous code block, if errno is zero, the normal flow continues. If errno is non-zero, nothing is done and the function returns with errno. Now, i found out a strange issue, errno that is initialized to 0 at the start of the function, changes its value to 9 after doing a sprintf call. sprintf call is successfull though. Another strange thing about it is that this happens only when the exe is run as service on Windows Vista. If the same exe is run from Visual Studio debugger, this behavior doesn't happen when exe runs from VS directly in either release or debug mode. I can not comprehend the behavior, any help will be appreciated. Thanks. Gajendra

      Gajendra

      G Offline
      G Offline
      Gajendra Sharma
      wrote on last edited by
      #2

      No answers at all....Surprising.

      Gajendra

      G 1 Reply Last reply
      0
      • G Gajendra Sharma

        No answers at all....Surprising.

        Gajendra

        G Offline
        G Offline
        Gajendra Sharma
        wrote on last edited by
        #3

        Ok..so nobody knows it....:-)

        Gajendra

        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