Often, the program will have errors when you attempt to compile, build, and execute it. The program that was successfully executed in the previous example has been modified to include an error—the semi-colon at the end of the return 0 statement has been removed. When the modified program is compiled, an error is displayed in the output window. (See Figure 13.)
Figure 13 Compile Error
You can determine where the compiler found the error by scrolling up in the Output window until the specific error message is visible, then by double-clicking on the error message in the Output window. This will cause a pointer to appear in the left margin of the source file where the error was encountered. (See Figure 14.)
Figure 14
Figure 15 Importing a File into a Project
Once the file is part of the project (it will be listed in the Source Files folder in the Solution Explorer pane) you can double-click its name to display it in the editor pane. Then you can compile, build, and execute the program as described above.
Summary
Microsoft Visual C++ allows you to create many different types of applications. This guide addressed creating and using single source file Console Applications, but the basic operations are the same for more complex programs. Always start by creating a project file of the appropriate type Create blank files for writing your own programs or import existing files into the project Compile Build Execute Debug, if necessary
Categories:
Programing With visual C++
Subscribe to:
Post Comments (Atom)
0 Response for the "Debug the Program visual C++"
Post a Comment