How to expand the array pointer in the Visual C + + Debugger Watch Window

Source: Internet
Author: User

How to expand Visual C + + array pointers in the Debugger watch Window

Profile

from Visual C + + 6.0 the beginning of the version can now expand the array to point to the Visual C + + View all array elements in the Debugger watch window. This feature is not logged. In the Watch window, type ...

Starting with Visual C + + version 6.0, you can now expand the array to point to view all array elements in the Visual C + + Debugger Watch window. This feature is not logged.

In the Watch window, type an expression that evaluates to a pointer followed by the number of elements in a comma and array.

More information

generate a debug version of the following code as a console application. //Filenamemain.cpp//No compile option needed #include ...

    1. Generate a debug version of the following code as a console application.
    2. 2.//filename main.cpp
    3. 3.//no compile option needed
    4. 4.
    5. 5. #include <iostream.h>
    6. 6.
    7. 7. void Main (void)
    8. 8. {
    9. 9. int * p;
    10. char* ptr = "Hello world";
    11. p = new int [10];
    12. for (int i=0; i<=9; i++) {* (p+i) = i+1;}
    13. cout << i <<endl;
    14. }

    1. Enter and step through the code using the debugger and stop at the last line of code.
    2. Add the variable pptr in the Watch or QuickWatch window. You'll see A + sign next to the variable.
    3. Click the + symbol to expand the variable. You will see the first element of the array it points to.
    4. Now, in theWatch window, type p,ten or ptr,one by one.
    5. Click the + symbol to expand the variable. Now, you see that it points to all the elements of the array.

If you want to view a specific range of elements, then enter the first element to specify the address of the starting index appended with the format specifier, as described in the previous steps. For example (p+3),8 shows elements p [3..10] and (ptr+3), and the element ptr [3..12] is displayed. Unfortunately, the index starting in the Watch window will actually correspond to index 3 in this example for [0]. You must remember that an offset of 3 has to be added to each displayed index to get the actual index of the array element.

How to expand the array pointer in the Visual C + + Debugger Watch Window

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.