CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Join Date
    Jun 2005
    Posts
    181

    Debugging Arrays

    Hi there,

    I am debugging a 8*8 array.

    When I view it in Auto or Locals and expand it all it shows is what I assume are the rows. the value for each row is simply shows as the memory location of the overall array.

    Is there a way for me to view the whole array i.e. by column and row?

    And to see the value stored in that location?

    also I have a value which I a static int which does not show up in either Auto or Locals how can I view the value of this variable when the program is running?

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Debugging Arrays

    You'd need to expand the rows too,

    Alternately you could use the watch or quick watch windows and type in something like myArray[1][2]

  3. #3
    Join Date
    Jun 2005
    Posts
    181

    Re: Debugging Arrays

    I cannot expand the rows?

    There is a box with a plus in it but nothing happens when I click on it?

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Debugging Arrays

    For dynamic-size arrays, you cannot expand an entire row by simply clicking next to it, since the debugger doesn't know how big it is. The syntax then would be,

    myArray[1],2
    in the watch window.

  5. #5
    Join Date
    Jun 2005
    Posts
    181

    Re: Debugging Arrays

    Quote Originally Posted by Lindley
    For dynamic-size arrays, you cannot expand an entire row by simply clicking next to it, since the debugger doesn't know how big it is. The syntax then would be,

    myArray[1],2
    in the watch window.
    ah that's it thanks to both of you!!!

    can you exaplin to me the syntax though

    the myArray[1] is obviously identifying the arrau and the row.

    Also can anyone exaplain to me how to view variables of type static int?

    It doesn't show up in either auto or locals and doesn;t seem to be doing its job in the program either!

  6. #6
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Debugging Arrays

    Just type the name of the variable in the watch window. If the var is within scope it should show you the value.

  7. #7
    Join Date
    Jun 2005
    Posts
    181

    Re: Debugging Arrays

    ahhhh

    It come sup with!

    step: CXX0017: Error: symbol "step" not found

    below is the code, why would this symbol not be found?

    Code:
    void updateMove(int board[][8],int moves[],int choice,int& x,int& y, int& movecounter)
    {
    	static int step =0;
    
    	step += 10;
    
    	movecounter += 1;
    	
    	board[x +=  horizontal[moves[choice]]][y +=  vertical[moves[choice]]] = step;
    }

  8. #8
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Debugging Arrays

    Which line was the debugger stopped on when it said that?

  9. #9
    Join Date
    Jun 2005
    Posts
    181

    Re: Debugging Arrays

    It is just on the closing brace.

    But I have not Pressed F11 to proces it yet.

    All other variables within that bloack are still viewable.

  10. #10
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Debugging Arrays

    Does it show up if you breakpoint before the closing brace?

  11. #11
    Join Date
    Jun 2005
    Posts
    181

    Re: Debugging Arrays

    no it has the same error:


    step CXX0017: Error: symbol "step" not found


    mo matter where you are in the program.

  12. #12
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Debugging Arrays

    Make sure optimization is disabled.

  13. #13
    Join Date
    Jun 2005
    Posts
    181

    Re: Debugging Arrays

    sorry what is optimsiation and how do I disable it?

  14. #14
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Debugging Arrays

    Project->Properties->C/C++->Optimization and set the first option to "Disabled". This should be the case by default in the Debug configuration.

  15. #15
    Join Date
    Jun 2005
    Posts
    181

    Re: Debugging Arrays

    OK I'm usig VC++ 6

    In Project settings>C/C++>under optimisations: it has Diable(debug) but this is ghosted out.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured