You will first see a welcome screen, select the “Not now, maybe later” option.
At the next screen just select the default (general) environment and press the start button. Once the program has loaded (this may take some time), you can should now go to the menu at the top and select to open a new project. Given that each and every time you want to create a new program you will need to go through this same process, you should bookmark this page for future reference.
From the available templates on the left hand bar, select “Visual C++” and then “Empty Project” from the centre window. Change the name of the project to something that makes sense (Assignment 1, Binomial Tree, etc.) and then click ok.
You should now have a blank project. In order to write code we now need to create a new cpp file. For the most part of this course you should work on a one file one project basis, there can be only one main source file so new problems will require a new project! Go to the right hand bar and right click on the “Source Files” directory, and from the resulting menu select “Add- >New Item”:
From this screen we can now add our cpp file, rename it to whatever you like and click add.
Now we need to put some code in that file, so copy/paste the following into the file:
// include the input output stream library // so that you can write to the screen #include <iostream> // use the std namespace using namespace std; // all programs must have just ONE main function // int main() { // output a message to the screen cout << " Hello world!!!!!\n"; // finish the function by returning an integer return 0; }
and then save the file.
You are now ready to compile and run your first c++ program. Go to the “DEBUG” menu at the top and select “Start without debugging”, or use the shortcut “Cntrl F5”. Click on yes to build your solution and you should see it compile and then a black window will momentarily appear and disappear again.
Obviously this is no good as you cannot see any output from the program. In order to fix this we need to go to the “PROJECT” menu and select the properties option for your project, my project is called “Project3” so I select “Project3 Properties...”.
Once the properties window is open select “Configuration Properties- >Linker- >System” in the left hand sidebar.
Now you need to change the “SubSystem” setting to get the program to stay on screen. Either by entering manually or by selecting from the drop down menu (press the small triangle on the right hand side) set this to
You are finally ready to go! Press “Cntrl F5” and yes to build the project and the black console will now stay on screen. You should see this:
NOTE: you will need to reset this option in the property pages every time you open a new project. After a few goes it will become like second nature ☺