| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I wish to use the Visual C++ debug feature to get a better idea on what exactly goes on step by step when this code (shown below) is run, and how my variables are affected. My request is: Can someone instruct me on how to use the debug feature for the stated purpose? Or can someone please direct me to a comprehensive guide for doing so? My thanks in advance. Code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char next;
cout << ": ";
cin.get(next);
while (next != ' ')
{
cout.put(next);
cin.get(next);
}
cin.putback(next);
cout << endl;
return 0;
}
|
|
#2
|
||||
|
||||
|
I dont really ever use the debug function but what exactly are you trying to get out of it. Are you just trying to see what your program is doing, step by step? Because this code is fairly basic, the first cin.get(next) starts the loop then the while loop, loops until the user presses enter. Then the cin.putback(next) prints what the user entered. Instead of while(next != ' ') you could use '\n' because the while will not stop just because the user presses the space key. So if you are just trying to explore your compiler I'm sorry I probably cant help you there but I hope this explanation helps you.
__________________
---Official Member Of The Itsacon Fan Club--- ![]() Give a man a fish and he will eat for a day. Teach a man to fish and he will sit in a boat all day drinking beer. |
|
#3
|
|||
|
|||
|
Quote:
Exactly. Yes, I know the code is fairly basic. However I am having trouble using the debugger to follow even this code. If anyone can show me how to set up the debugger so I can follow this code, please let me know. Thank you. |
|
#4
|
|||
|
|||
|
In one of my labs we use the Visual C/C++ debugger to both view the assembler code and also to set things like 'watch' vairables and break points.
If you don't have an answer by thursday or so I will have a look to remind myself and get back to you, as I'm not in the lab until then. |
|
#5
|
|||
|
|||
|
Quote:
Thanks Neuro, I appreciate it. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Need Instructions on HOW to debug this small code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|