Table of Contents
To start Microsoft Visual Studio go to the Start button, then Programs, then Microsoft Visual Studio 6.0, and finally Microsoft Visual C++ 6.0. Visual Studio should then start with Microsoft Visual C++ displayed in the main window title bar (at the top of the window).
To create an run a C program:
To start you should have Microsoft Visual Studio running. To do so follow the directions for Starting Developer Studio.
To create a C source code file follow the directions for creating a text file except use the filename extension "c", i. e. name the file MyProgram.c, Test.c, Assign1.c, etc. This is very important!
Building a program involves first compiling your source code into a form the computer can understand and interpret and, then "linking" your compiled code with other code that is required to make your program run. During compilation the compiler will check for errors in your code and may issue a number of error messages and warnings. If there are severe errors, your program will not be linked and will not run.
To "build" your program go to the Build menu and choose the Build command. If you have not saved your file you will be prompted with the message "Save changes to filename" where filename is the name of your file. You should generally choose Yes to save your file before running your program. The first time you choose the Build command each session you will also receive the message "This build command requires an active project workspace. Would you like to create a default project workspace?" You should respond by choosing Yes; for now you can ignore the project workspace and its meaning.
After you have chosen Build and the project workspace has been created, your program will start to compile. If there are fatal errors in your program, they should be listed in a window at the bottom of the Visual Studio workspace. To go to a line in your source code where an error was detected, you can double-click on the error message in the window at the bottom of the VS workspace. If there are errors in your source code you should correct them by editing your ".c" source code file and choosing the "Build" command again. Repeat this process until there no errors are detected in your program. [Note: Once you have chosen the Build command the first time, the command will appear in the Build menu as Build filename.exe, where filename represents the name of your source code file (without the "c" extension).]
Once you have successfully compiled and linked your program, you can run it by going to the Build menu and choosing Execute filename.exe where filename is the name of your program. You can also run your program by pressing Ctrl+F5 (hold down the Ctrl key and then press the F5 key while still holding the Ctrl key down.).
You can also run your program with the debugger by going to the Build menu, choosing the Start Debug item, which will then present a submenu from which you should choose Go. You can also run the program with the debugger by pressing the F5 key.
To create an run a C program:
First, create a program and compile it. To do so you can follow the directions for Creating and Running a C Program.
You can either run the debugger starting at the beginning of your program a stepping through the instructions one by one, or you can run the debugger by stepping at a point ("breakpoint") that you have chosen.
To start debugging at the start of your program go to the Start Debug item in the Build menu and choose Step Into from the popup (hierarchical) sub-menu that appears. Your program will then load and begin execution at the start of the program. You are then ready to run your program by stepping through the instructions line by line. To advance one instruction at a time you can press either the F10 or F11 key. If you press the F11 key you will step into the code for each function that you encounter; if your choose F10, your program will simply step over each function and not step you through the lines of code in the function itself. If your program is just one main program, it is probably best and easiest to understand what is happening to use the "Step Over" (F10) key.
As you step through each line of code you can examine the values of variables in the Debug window that appears at the bottom of the screen.
Instead of running the debugger and having to step through every line of your code to get to the point you are really interested in, you can set "breakpoints". With breakpoints set you will run your program until you reach the point where the breakpoint has been set. You can then step through the lines of your code beginning at the breakpoint. Also, at any time you can resume running your program until the next breakpoint is encountered.
Before you can run using breakpoints, you must first set breakpoints where you want your program to stop. To set a breakpoint, open the program file (the file with the ".c" extension) and go to the point where you want the breakpoint set. Place the cursor on the line where the breakpoint is to be set and press the F9 key. A brown circle should then appear in the left margin to indicate that a breakpoint has been set at that line.
Once you have set breakpoints at the points desired, go to the Start Debug item in the Build menu and choose Go from the popup (hierarchical) sub-menu that appears. You can also start your program by pressing the F5 key. Your program should then run until it reaches the line where the first breakpoint has been set. Once the breakpoint is reached, you can step through your code line-by-line using the F10 or F11 keys as described above, or you can have the program run until it encounters the next breakpoint. To run the program to the next breakpoint press the F5 key.