Frequently Asked Questions (FAQ)

About Microsoft Visual Studio C++


  1. What is Microsoft Visual C++?
  2. How do I start up Visual C++?
  3. How do I create a project/solution?
  4. How do I add other projects to the solution?
  5. How do I add a source (.cpp) file or header (.h) file to my VS-C++ project?
  6. How do I remove a source file or header file from my VS-C++ project?
  7. How do I compile and run my program?
  8. How do I choose which project in the solution to run?


Related Questions

  1. How do I make Windows show the extensions on file names so I'll know which files are which in my projects? (Other versions of Windows require the same actions but things are located in different places.)
  2. How do I make VS stop giving warning and error messages about using standard Kernighan and Ritchie char array string functions?
  3. Where can I get additional help?


Free Copies of Visual Studio

  1. Where can I get a free copy of the latest version of Visual Studio?
  2. Where can I get a free copy of Visual Studio 2012 (Recommended version)?





What is Microsoft Visual C++?

    Microsoft Visual Studio is the recommended compiler used to write, compile, and run the programming assignments for all classes in the Computer Science Department. Visual Studio is an Integrated Development Environment (IDE), meaning it contains a sosurce code editor for writing programs, a compiler for compiling source code into an executable program, and a run time environment in which you can run and debug programs.

    You can create projects in which you program not only in C++, the language for this course, but also in Visual Basic, C#, and J#.
    As a student enrolled in a course in this department you may use Visual Studio on any of the computers in the labs. You may also get a copy to install on your home computer. See one of the graduate assistants on duty in the labs for instructions. They will tell you how to sign up for a copy and how to download and install it. Or, if you are feeling adventurous go to the CS web site http://www.cs.uah.edu, click on the Resources menu, select "MSDN Academic Alliance Software" and follow the instructions there to obtain a copy of Visual Studio or any of the other software packages available to you.


How do I start up Visual C++?

  1. Left click the round MS Windows logo button in the task bar at the lower left corner of the screen.
  2. Select All Programs
  3. Select the Microsoft Visual Studio 2008 folder then select the Microsoft Visual Studio 2008 application icon.
  4. Microsoft Visual Studio will start up. If you are working in the UAH computer lab it may take a few seconds because your computer has to download the software over the network from the server, so be patient. If this is the first time you have run Visual Studio on this computer then you may see a dialog box asking you to select the programming language to use. Select Visual C++ Development Settings then click the Start Visual Studio button. The first time it may take several minutes before Visual Studio is ready to use.


How do I create a project/solution?

In Visual Studio the first thing you will do is create a project to work on. To do this follow these steps:
 
  1. From the File menu select File->New->Project and the dialog box shown below will appear.

  2. In the dialog box that appears make sure that Visual C++ is selected in the Project Types hierarchy tree on the left. Note: your list of project types may be slightly different if other languages have not been installed. Under Visual C++ select Win32.

  3. Select Win32 Console Application from the options under Templates

  4. Enter a name for the project in the text box labeled "Name". In this example the project will be named "ProgrammingAssignment1".

  5. Click the browse button then locate the folder in which you want to create the new project. It is recommended that you keep your projects on your own thumb drive. Any project created on a computer in the labs will only be accessible from that computer, and could be deleted without warning by the computer lab staff during maintenance upgrades.

  6. Enter a name for the solution in the text box labeled "Solution Name". In this example the solution will be named "ProgrammingAssignments". A "Solution" is Microsoft's term for your project workspace. After creating a solution with your first project you can then add other projects to the solution. Some programmers like to put only one project in a solution to keep everything neat and separate. Others prefer to put all programming assignment projects for a course in the same solution.


    Visual Studio 2015 image.

  7. Click the OK button and the Win32 Application Wizard window will appear. Select "Application Settings" from the list on the left and the window shown below appears. Make sure that the "Console Application" radio button is selected. Uncheck the "Precompiled Header" and the "Security Development Lifecycle" check boxes. Check the "Empty Project" check box. This will ensure that you will be building a pure ANSI Standard C++ application without any of the extra baggage with which Microsoft likes to load you down.


    Visual Studio 2015 image.

  8. Finally click "Finish" and your project will be created.


How do I add a project to a Solution?

 
  1. Left click the solution name in the Solution Explorer pane of Visual Studio. From the popup menu that appears select Add->New Project.



  2. The dialog box shown below will appear.


    Visual Studio 2015 image.

  3. Select Visual C++ from the Project types list on the left and select Win32 under Visual C++. Select Win32 Console Application from the list on the right.
  4. Enter a name for the Project in the text box labeled "Name". In this example the new project will be named "Prog2". Use the default location as this will be the solution directory. Note that the Solution Name text field does not appear in this dialog box since you are adding a project to an existing Solution.
  5. Click the OK button and the Win32 Application Wizard window will appear. Select "Application Settings" from the list on the left and the window shown below appears. Make sure that the "Console Application" radio button is selected. Uncheck the "Precompiled Header" and the "Security Development Lifecycle" check boxes. Check the "Empty Project" check box. This will ensure that you will be building a pure ANSI Standard C++ application without any of the extra baggage with which Microsoft likes to load you down.


    Visual Studio 2015 image.

  6. Finally click "Finish" and your project will be created.



How do I add a source (.cpp) file or header (.h) file to my VS-C++ project?

    Adding a new source to the project directory.
    1. Right click the project's "Source Files" folder and select Add->New Item from the pop-up menu.



    2. The dialog box shown below will appear (your version of Visual Studio may look slightly different). Select Visual C++ in the left pane and Code under that.

    3. Select C++ File (.cpp) in the right pane.

    4. Enter a name for the .cpp file in the Name text box below. Use the default location.



    5. Click the Add button and the blank file will be created and opened in the editor. This would be a good time to type in the required header comment. This is required on all source files (both .cpp and .h) you turn in for a class in the Computer Science Department. This must include the name of the file, your name, an identifier for the project/assignment, and finally the statement "This program is entirely my own work." This is considered your official statement that you wrote this code and did not copy it from anyone else. Copying the code from another student is considered cheating and will result in zero points for an assignment. It could result in an automatic F in a course, and even suspension from UAH. Don't risk it. Instructors can spot duplicate code easily.
       
      //---------------------------------------------------------------------------- 
      //  Source Code File Name 
      //  Your Name 
      //  Programming Assignment number and name 
      //  This program is entirely my own work 
      //---------------------------------------------------------------------------- 
      
    6. To create a header file follow the same procedure but right click the "Header Files" folder, select "Add->Add New Item...", then select "Header File (.h)". Enter a name for the header file then click the Add button to create it.

    Adding a source file that has been copied into the project directory.
      Sometimes you may want to reuse code from a previous project such as when a second programming assignment builds on what you wrote for the first assignment. To do this you must first copy the source code file from the old project directory into the new project directory. Do this from a Windows explorer window not within Visual Studio. After copying the file do the following:
    1. Right click the Source Files folder and select "Add->Add Existing Item...". Select the .cpp file from the dialog box list that appears.
    2. To add a header file that has been copied from another place into the project directory right click the Header Files folder and select "Add->Add Existing Item...". Select the .h file from the dialog box list that appears.

How do I remove a source file or header file from my VS-C++ project?

  1. Select the file which you wish to delete in the Solution Explorer pane.
  2. Press the Delete key.

How do I compile and run my program?

  1. Pull down the Build menu and select "Build ProjectName".
  2. Visual Studio will compile your program. If there are any errors or warnings these will be listed in the pane at the bottom of the Visual Studio window. Fix these errors and warnings then compile again.
  3. If the program compiles then from the Debug menu select Start Debugging to run the program with the debugger or Start Without Debugging to run the program without the debugger.

How do I choose which project in the solution to run?

  1. Right click the name of the project you want to run in the list of projects in the Solution Explorer pane.
  2. In the pop-up menu select "Set as Startup Project". Now when you select Debug->Start Debugging or Debug->Start Without Debugging this is the project that will be run.

How do I make Windows show the extensions on file names so I'll know which files are which in my projects?

  1. Click the folder icon in the Taskbar.

  2. Move the mouse cursor anywhere in the window that appears and press the Alt key. The menubar will appear.

  3. From the Tools menu select Folder Options.

  4. In the dialog box that appears select the View tab then uncheck the option to "Hide extensions for known file types". Finally, click the OK button. All file extensions will now appear in Windows Explorer and other dialog boxes.




Where can I get additional help?

  1. Select from the Help menu in Visual Studio.
  2. Ask a graduate lab assistant on duty in one of the CS labs.
  3. Ask the instructor.

Where can I get a free copy of the latest versoin of Visual Studio?

 
  1. Open any browser and go to the Computer Science intranet page. This can be found at http://www.cs.uah.edu/intranet.

  2. Click on the link that says "Department-licensed software (MSDNAA)". The display in the center of the Intranet page will change.



  3. Click on the link that says "visit the MSDNAA web store".



  4. Click Start Shopping.



  5. Log in with your Computer Science account user name and password.



  6. Enter "Visual Studio" in the Product Search text field then press Enter. You will probably want to look at all the other software you can download free from the MSDNAA site.





Where can I get a free copy of Visual Studio 2012 (Recommended version)?

 
  1. Find the installer on the K drive on any computer in the labs at K:\Courses\CS221\VisualStudio2012Ultimate and copy the file en_visual_studio_ultimate_2012_x86_dvd_920947.iso to your desktop.
  2. Right click the file and select Mount (VCD 1:)(en_visual_studio_ultimate_2012_x86_dvd_920947.iso)). This will mount the virtual drive as a BD-ROM Drive on your computer.
  3. Select the virtual drive in Windows Explorer then double click vs_ultimate.exe to install.


How do I make VS stop giving warning and error messages about using standard Kernighan and Ritchie string functions?

 
  1. Right click the name of your project in the Solution Explorer pane and select Properties from the pop-up menu. It should be the last item in the menu.

  2. In the dialog box that appears select C/C++ then under that Advanced in the column on the left.

  3. Click in the text field to the right of Disable Specific Warnings and enter 4996.

  4. Click the OK button.



    If you switch from debug mode to release mode in Visual Studio you will have to set this again.