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. the debug problem in VC++

the debug problem in VC++

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelpquestion
6 Posts 6 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.
  • W Offline
    W Offline
    wendyyue
    wrote on last edited by
    #1

    say i have a function int fun(int *a), and other function int fa(); int fb(), int fc(),....int fn(); all the them will call the fun(int *a), but the problem is, when I run the program, the vc++ tells me some of them pass the NULL pointer to the fun(int *a) which make mistake, but could not tell me which function calls the fun(int *a) and then pass the NULL pointer to it, so dear guys, how could I know which one call the fun(int *a) that pass the NULL pointer? Thanks.

    C R S D H 5 Replies Last reply
    0
    • W wendyyue

      say i have a function int fun(int *a), and other function int fa(); int fb(), int fc(),....int fn(); all the them will call the fun(int *a), but the problem is, when I run the program, the vc++ tells me some of them pass the NULL pointer to the fun(int *a) which make mistake, but could not tell me which function calls the fun(int *a) and then pass the NULL pointer to it, so dear guys, how could I know which one call the fun(int *a) that pass the NULL pointer? Thanks.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      :confused: I didn't really understand your problem. Do you have a crash and would like to find the problem ? If yes, did you use your debugger to track the problem ? Using the callstack you'll be able to find which function passed a NULL pointer.

      Cédric Moonen Software developer
      Charting control [v1.3]

      1 Reply Last reply
      0
      • W wendyyue

        say i have a function int fun(int *a), and other function int fa(); int fb(), int fc(),....int fn(); all the them will call the fun(int *a), but the problem is, when I run the program, the vc++ tells me some of them pass the NULL pointer to the fun(int *a) which make mistake, but could not tell me which function calls the fun(int *a) and then pass the NULL pointer to it, so dear guys, how could I know which one call the fun(int *a) that pass the NULL pointer? Thanks.

        R Offline
        R Offline
        rp_suman
        wrote on last edited by
        #3

        Hi, If your program stops with runtime error, as Cedric said, use the "call stack" window and see which one of fa(), fb().. fn() is called just before fun(). Or try using only one function from fa(), fb() ... fn() at a time and find out. If you have problem still post the relevant code snippet. Best Regards, Suman

        -- "Programming is an art that fights back!"

        1 Reply Last reply
        0
        • W wendyyue

          say i have a function int fun(int *a), and other function int fa(); int fb(), int fc(),....int fn(); all the them will call the fun(int *a), but the problem is, when I run the program, the vc++ tells me some of them pass the NULL pointer to the fun(int *a) which make mistake, but could not tell me which function calls the fun(int *a) and then pass the NULL pointer to it, so dear guys, how could I know which one call the fun(int *a) that pass the NULL pointer? Thanks.

          S Offline
          S Offline
          Saurabh Garg
          wrote on last edited by
          #4

          Well one way like others said, if you are programming in Visual Studio, you can set break point and check the call stack when program crashes. Another way is to do it like this: int fa() { int* a; . . . if(a == NULL) { cout << "fa is the culprit"; } fun(a); } -Saurabh

          1 Reply Last reply
          0
          • W wendyyue

            say i have a function int fun(int *a), and other function int fa(); int fb(), int fc(),....int fn(); all the them will call the fun(int *a), but the problem is, when I run the program, the vc++ tells me some of them pass the NULL pointer to the fun(int *a) which make mistake, but could not tell me which function calls the fun(int *a) and then pass the NULL pointer to it, so dear guys, how could I know which one call the fun(int *a) that pass the NULL pointer? Thanks.

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

            Use the debugger to set a breakpoint in fun(). When a equals NULL, check the call stack.

            "Love people and use things, not love things and use people." - Unknown

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            1 Reply Last reply
            0
            • W wendyyue

              say i have a function int fun(int *a), and other function int fa(); int fb(), int fc(),....int fn(); all the them will call the fun(int *a), but the problem is, when I run the program, the vc++ tells me some of them pass the NULL pointer to the fun(int *a) which make mistake, but could not tell me which function calls the fun(int *a) and then pass the NULL pointer to it, so dear guys, how could I know which one call the fun(int *a) that pass the NULL pointer? Thanks.

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

              Did you get runtime error?

              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