Our Environment We will exercise on Microsoft Visual C++ v. 6 n because that is what we have in the univ. n but there are many free compilers, too. n
Visual C++ (v 6)
Visual C++ (v 6) New. . Ctrl+N
Visual C++ (v 6) project title (name of. exe) Project and file directory Choose: “Win 32 Console Application”
Visual C++ (v 6)
Visual C++ (v 6) New source file will be included in the project
Visual C++ (v 6) Choose: “c++ source file” Give a file name with extension. c
Visual C++ (v 6) Write your program here
Visual C++ (v 6) Compile the C file
Visual C++ (v 6) Build an executable (. exe) file.
Visual C++ (v 6) Run the executable file (. exe). When this menu is selected, even if the compiling was not complete, it will re-compile. Error and warning messags will be here.
Visual C++ (v 6) Program output and interface at DOS prompt.
Visual C++ (v 6) Open a previously created project.
Visual C++ (v 6)
Compiler structure
Program generation steps
Error investigation There is a variable which is forgotten to be declared before used. By double clicking on the error message, you can go to the line containing the error.
Debugging Add an integer variable with name “a”
Linker errors A function with name “print” is not defined.
The correct one should be printf
Execution error
The correct usage of printf for writing out numbers
Debugger
Until now, you should have encountered programming mistakes. Use debugger: Build->set active configuration-> win 32 debug
Insert breakpoint Chose line Start debugging with “F 5” or Build->Start Debug->Go Put break point
Debug screen Debug toolbar Current running line Functions Stack Variables watching
Run line by pressing “F 10” or clicking this button Trace variable values here
Move mouse over the variable name, and see the current values
To execute and skip to the next breakpoint, press “F 5”