Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Sign in to follow this  
Blackbound

Tatsu/Blackbound's C++ tutorial

Recommended Posts

Index

 

 

Part 1: Getting and installing your compiler[P2:0x1]

Part 2: Your Basic C++ Program [P3:0x2]

 

 

Getting and installing your compiler[P1:0x1]

Now to get your Compiler. Select Visual C++ Express

Edition. Once you have it downloaded, run it and do something that doesn't involve the computer or the internet

for an hour or so (yes it takes forever to install). Once you have it installed run it, and wait for it to set up

and load. Before we get into any coding, I want you to go to Tools->Options... and click the plus next to Text

Editor, Click on All Languages (not the plus next to it) and make sure there is a check in the box that says "Line

Numbers," make sure that is checked so you can find your errors faster. Click OK.

 

Your Basic C++ Program[P2:0x2]

Create a new project by going to File->New->Project. Pick CLR Empty Project and name it as "MyFirstProgram" Once

you have that done, you will see on the bar to the left that says "Solution explorer" has the name of your program.

Right click on where it says "Source Files" and hit Add->New item and pick "C++ file (.cpp)" and name it Main

now copy the below code and put it into the file you just created and we will dissect it piece by piece.

 

#include<iostream>
using namespace std;


int main(){
cout << "Hello World" << endl;
system("pause");
return 0;
}

 

before we start dissecting it, lets make sure it works first. Go to Build->Build Solution or hit F7. (It should

work, the only reason it might not have worked would be user error)

 

#include<iostream>

this includes the file "iostream.h" from the main source library.

#include <from library> or #include "from local directory"

 

using namespace std;

This tells the compiler we are using the namespace "std" (Which stands for Standard not Sexually Transmitted

 

Desease)

 

int main () {

We are opening a function titled Main, It take no arguments and returns an integer.

 

cout << "hello world" <<endl;

we are using the standard library function "cout" (pronounced C out) to tell the compiler to display "Hello World"

 

and then start a new line.

 

system("pause");

This tells the system to pause what its doing and wait for user input and displays "Press any key to continue"

 

return 0;

This tells the program to return the number 0 as the Main function's ouput

 

}

this signifies the end of the main function and should not be forgotton. If you forget this your code will screw

up.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...