debugging VS6.0 C (not ++)... how to view entire array contents?
-
Folks, Using the Visual C++ 6.0 debugger, how can I view (or better, print to file) the contents of an array of doubles? I know I can see the address of the array variable and the contents of the first member element using the Quickwatch or watch window, but I need to examine the entire contents of the array (length ~300 elements). I can't use the TRACE macro because this app does not use MFC (and it's coded in 'C', not C++). I think I recall a notation style one could type into the QuickWatch window that would do this but I've forgotten it. TIA!
'til next we type... HAVE FUN!! -- Jesse
-
Folks, Using the Visual C++ 6.0 debugger, how can I view (or better, print to file) the contents of an array of doubles? I know I can see the address of the array variable and the contents of the first member element using the Quickwatch or watch window, but I need to examine the entire contents of the array (length ~300 elements). I can't use the TRACE macro because this app does not use MFC (and it's coded in 'C', not C++). I think I recall a notation style one could type into the QuickWatch window that would do this but I've forgotten it. TIA!
'til next we type... HAVE FUN!! -- Jesse
Just click the '+' sign next to the variable's name. You can also look at individual items using square brackets (e.g.,
MyArray[2]
,MyArray[4]
).
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
-
Folks, Using the Visual C++ 6.0 debugger, how can I view (or better, print to file) the contents of an array of doubles? I know I can see the address of the array variable and the contents of the first member element using the Quickwatch or watch window, but I need to examine the entire contents of the array (length ~300 elements). I can't use the TRACE macro because this app does not use MFC (and it's coded in 'C', not C++). I think I recall a notation style one could type into the QuickWatch window that would do this but I've forgotten it. TIA!
'til next we type... HAVE FUN!! -- Jesse
-
Folks, Using the Visual C++ 6.0 debugger, how can I view (or better, print to file) the contents of an array of doubles? I know I can see the address of the array variable and the contents of the first member element using the Quickwatch or watch window, but I need to examine the entire contents of the array (length ~300 elements). I can't use the TRACE macro because this app does not use MFC (and it's coded in 'C', not C++). I think I recall a notation style one could type into the QuickWatch window that would do this but I've forgotten it. TIA!
'til next we type... HAVE FUN!! -- Jesse
I'm assuming that your array is allocated with "new", otherwise simply clicking on the + button would expand your entire array. If that's the case:
double *pMyDouble = new double[300];
then in your watch you can simply usepMyDouble,300
That will show 300 elements of type double. Hope that helps.Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
Folks, Using the Visual C++ 6.0 debugger, how can I view (or better, print to file) the contents of an array of doubles? I know I can see the address of the array variable and the contents of the first member element using the Quickwatch or watch window, but I need to examine the entire contents of the array (length ~300 elements). I can't use the TRACE macro because this app does not use MFC (and it's coded in 'C', not C++). I think I recall a notation style one could type into the QuickWatch window that would do this but I've forgotten it. TIA!
'til next we type... HAVE FUN!! -- Jesse
You should be able to use either the [] operator or write it as *(myVar + index) -- where myVar is the array and index is the number of the element you want to view. If you need/want to see the entire array, you might want to open a file and have its output saved to it at various points in time.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Just click the '+' sign next to the variable's name. You can also look at individual items using square brackets (e.g.,
MyArray[2]
,MyArray[4]
).
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
Thanks, but I need to see the contents of the entire array at once. Clicking the + only shows the first element because the array variable is really a pointer allocated dynamically.
'til next we type... HAVE FUN!! -- Jesse
-
kuphryn wrote:
operator []
This application is straight 'C', not C++.
'til next we type... HAVE FUN!! -- Jesse
-
I'm assuming that your array is allocated with "new", otherwise simply clicking on the + button would expand your entire array. If that's the case:
double *pMyDouble = new double[300];
then in your watch you can simply usepMyDouble,300
That will show 300 elements of type double. Hope that helps.Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
krmed wrote:
pMyDouble,300
Aha! You've won yourself a cupie doll! That's the Watch Window notation I had forgotten. Thanks a bunch!
'til next we type... HAVE FUN!! -- Jesse
-
You should be able to use either the [] operator or write it as *(myVar + index) -- where myVar is the array and index is the number of the element you want to view. If you need/want to see the entire array, you might want to open a file and have its output saved to it at various points in time.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
Zac Howland wrote:
use either the [] operator or write it as *(myVar + index)
and
Zac Howland wrote:
want to see the entire array, you might want to open a file
I need the entire array at once, preferably in a file, but I'd like to get it without adding more code to the app. Another CP user mentioned the myArray,300 notation which display the first 300 members of an array. That should work if I can find a way to capture that to a file.
'til next we type... HAVE FUN!! -- Jesse
-
Folks, Using the Visual C++ 6.0 debugger, how can I view (or better, print to file) the contents of an array of doubles? I know I can see the address of the array variable and the contents of the first member element using the Quickwatch or watch window, but I need to examine the entire contents of the array (length ~300 elements). I can't use the TRACE macro because this app does not use MFC (and it's coded in 'C', not C++). I think I recall a notation style one could type into the QuickWatch window that would do this but I've forgotten it. TIA!
'til next we type... HAVE FUN!! -- Jesse
You can enter the address of the start of the array in the memory window, then cycle through the display formats with Alt+F11 until you come to the right one (there are 14 views - just try them until you see
double
values ;))--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ