1. Open up VS(Visual Studio) from the Windows start menu. (duh!!)
3. Choose new project from the main page and make the language highlighted says C++.
4. Choose Win32 console application and give the rpoject a name (I called mine hello world).
5. Choose OK and then click next on the next screen. Choose to make it a blank project under other options.
6. We're almost ready to start coding. On the pane on the left of the screen right click on source files (this folder will hold all of the source code files you weite). Choose Add -> new file. Then choose C++ Source file and call the file hello.cc or .cpp or whatever want as long as it ends in .cc or .cpp.
7. The white screen you see in the middle of the IDE is the text editor where you will actually write the code at.
8. Now for the code!!!! put the following in the text editor:
#include
using namespace std;
int main()
{
cout << "Hello world!" << endl;
cin.get();
return 0;
}
9. Before we compile this code and see the magic I would like to explain it. #include
int main() is the start of a function. It tells the compiler to execute the code between the following { and } together. every C++ program starts with a main function. the int at the beginning tells the compiler that it will return an integer value when it succesfully completes.
the next line cout << "Hello world!" << endl; tells the computer to output the text between "" which in this case is Hello world!. endl tells the compiler to move to the next line.
Then in the next line you will see cin.get();. This actually tells the program to pause until it receives input from the standard input(keyboard in this case). When we execute the program, we will see the program pause after it outputs text to the screen. If we didn't have this line the program would run very quickly and you would not have time to see the program execute.
The last line is return 0; and it tells the program to return the number 0 when it properly executes.
10. OK so now we're ready to actually compile and run the program. Press F5 on the keyboard and you will see the VS IDE run through some stuff in the lower part of the screen and then you'll see the words you type in appear in a DOS command window. Press any key on your keyboard and then the enter key and it will complete it's execution.