Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi, guys!

I need to know the last values stored in variables and arrays after the program has run (successfully, I hope).
Matlab does it by ways of its Workspace.
How can I do that in Visual Studio C++ 2010?
Believe me, I've tried to find a way through the option menues, but, so far, no success.
THANKS IN ADVANCE.
Posted
Comments
Sergey Alexandrovich Kryukov 1-Mar-12 4:05am    
The question is not correctly formulated.
When the program has run, the variables do not exist.
If you mean some set of variables after some call(s), 1) there is no such problem; encapsulate all your data in one class and inspect it; 2) this is a sign of really bad programming practice.

No, first please explain the ultimate goal of this activity, to get a change to receive a good advice.
--SA
Lakamraju Raghuram 1-Mar-12 4:13am    
The OP says that he want to know the last stored/modified values of some variable."know the last values stored in variables and arrays... ".
Lakamraju Raghuram 1-Mar-12 4:14am    
And when the program ran, even the encapsulated data will vanish unless untill is is persisted to some storage. Isn't !!!
Lakamraju Raghuram 1-Mar-12 4:18am    
I feel all he wants is to monitor few variable (so only he mentioned that he tried to do the same through option menus/tools). So only I asked him to try doing it in debug mode. Hope I got him correct
Wilmer Lameda 1-Mar-12 9:29am    
Yes, you did. All I want to do is occasionally monitor some of my variables and arrays to see if my functions have been written correctly and the program logic is right. I've tried cout and got a different error every time. And I know everything that is not written to disk is dead after the program has run. THANK YOU.

1 solution

It all depends on the scope of the variables you are monitoring.

If the scope of the variables is through out the program you can print their values just before the program exits

If they are local, then you can print them just before they go out of scope.

Also you can use VS debug mode (F5) to monitor your program step by step.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900