Running a .cpp file in Microsoft Visual C++ Express Edition for the first time:


1.  Open MS Visual C++ application from start menu.

2.  Click the link "New Project".

3.  Select "Empty Project" from the list

      - give it a name that you haven't used before

      - indicate the location you want it

      - click OK

4.  Right click on "Source Files", and select "Add New Item" from the pop-out menu

5.  Select "C++ File (.cpp)"

      - give it a name that you haven't used before

      - indicate the location you want it (why not just use the same directory you already selected)

      - click Add

6.  Should now see a blank input screen for the filename.cpp that you just typed in

7.  Type in the C++ program that you wrote, or use one like this below:



// Simple test program, it just adds two numbers

#include <iostream>

using namespace std;


int main()


   int integer1, integer2, sum;             // declaration


   cout << "Enter first integer:" << endl;  // prompt

   cin >> integer1;                         // read an integer

   cout << "Enter second integer:" << endl; // prompt

   cin >> integer2;                         // read an integer

   sum = integer1 + integer2;               // assignment of sum

   cout << "Sum is " << sum << endl;        // print sum


char b; cout << "Enter anything";  cin >> b;


   return 0;   // indicate program ended successfully



8.  Save it (File menu).  Remember you already named it in step 5, so all you have to do is save.

9.  From the menu bar, compile by selecting Debug -> Build (or just hit F7 key)

10. Note the status window below, indicating compile status (succeeded, failed...)

11.  If compile was successful (no syntax errors, etc.), run it with the F5 key.

12.  Output appears in console window.  Remember input only takes place after you hit the Enter key.