MS VC++ 6 Debug Help

This is a discussion on MS VC++ 6 Debug Help within the C++ Programming forums, part of the General Programming Boards category; Hi, Im trying to use debug mode to inspect values of variables and structs. I can view the contents of ...

  1. #1
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69

    MS VC++ 6 Debug Help

    Hi,

    Im trying to use debug mode to inspect values of variables and structs. I can view the contents of a single variable easily by right clicking it in debug mode and adding a "Quick watch". I would like to be able to so a similar thing with structs but it always shows them as {...} rather than the data item(s) they contain.

    Any ideas how to do this?

    Thanks

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Quote Originally Posted by explosive
    Hi,

    Im trying to use debug mode to inspect values of variables and structs. I can view the contents of a single variable easily by right clicking it in debug mode and adding a "Quick watch". I would like to be able to so a similar thing with structs but it always shows them as {...} rather than the data item(s) they contain.

    Any ideas how to do this?

    Thanks

    You can usually expand classes, unions and structs. Is there a little '+' mark next to it? If not it may be because the struct is not in scope.

  3. #3
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    there is no + mark next to it. Just "rental {...}" ive attached a screenshot to show what i mean.
    Attached Images Attached Images  

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,803
    How is your rental variable defined and also the underlying struct? I've always been able to get a + that I can click on to expand the structure. Is rental a pointer to a dynamically allocated array of whatever struct type or is it a static array?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Have you tried typing "rental[0]" into the expression box?

  6. #6
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    this is the rental struct:
    Code:
    struct rental
    {
    	unsigned long int rental_id;
    	unsigned long int mem_num;
    	unsigned long int dvd_vid_num;
    	int date_due_dd;
    	int date_due_mm;
    	int date_due_yyyy;
    };
    I want to be able to inspect the contents of each of the variables inside it.

    edit:
    Quote Originally Posted by Fordy
    Have you tried typing "rental[0]" into the expression box?
    Tried it and the {...} is replaced with blank space.
    Last edited by explosive; 01-18-2005 at 05:45 AM.

  7. #7
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,803
    Well, from your description rental is a single struct and not an array of structs. Why are you using array notation here (i.e. rental[0])? Is there something else we are not seeing?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  8. #8
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    it is an array of structs.

    Code:
     rental rental[100];
    sorry forgot to put that before

  9. #9
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,803
    Well, I tried to follow what you say you have and everything seems to work as it should. I get a + that I can click on to expand the array. Hmmm... maybe it has to do with your build options? Also, have you applied the latest service pack?

    [edit]You say this happens when doing a "quick watch" correct? How about when using the standard watch windows? When you debug your program and hit a break point, go to the View Menu->Debug Window->Watch (Alt+3) options which should bring up a watch window somewhere on your screen. From there you should be able to type in the name of whatever variable you are trying to look at in the grid provided under the "name" column (for instance you would type "rental"). There should be a + available for you to click on and expand the tree.[/edit]
    Last edited by hk_mp5kpdw; 01-18-2005 at 10:52 AM.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  10. #10
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    I have service pack 6.

    Ive just tried using the ful watch window and entered "rentals" and it displayed {...} in the column to the right.

    I must be doing something wrong.... its driving me nuts as i cant debug my program >____<

    Ill try and explain in detail what i do to see if you can spot the problem.

    1. Debug--->Run To Cursor.
    2. When it breaks back to the source code i press F10 (step over) a few times to move along to the point i need.
    3. I then highlight "rentals" and select quick watch, which displays {...} for the rentals item.
    4. The same thing happens using the main watch window.

    NOTE: i can do this same procedure for variables that are on their own ie not in a struct and it works fine and displays the contents of them.


    Does it look like im doing something wrong?

  11. #11
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    Solved!

    I changed:

    Code:
    rental rental[100];
    to

    Code:
    rental rent[100];
    which made it work. It obviously didnt like the name of the struct being used for the name of the array of structs.

    Thanks for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Speed test result
    By audinue in forum C Programming
    Replies: 4
    Last Post: 07-07-2008, 05:18 AM
  2. makefiles - debug & release?
    By cpjust in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 04:00 PM
  3. Difference in MSVC 6 & MS VC .Net
    By passionate_guy in forum C Programming
    Replies: 1
    Last Post: 01-23-2006, 05:39 AM
  4. Ping
    By ZakkWylde969 in forum Tech Board
    Replies: 5
    Last Post: 09-23-2003, 12:28 PM
  5. The Timing is incorret
    By Drew in forum C++ Programming
    Replies: 5
    Last Post: 08-28-2003, 04:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21