EOSERV Wiki > Page: C plus plus Guide Hello World > History > Revision Diff

Revision Diff: C plus plus Guide Hello World

Revision by at 14th Jul 2011 04:21 pm
DeletionsAdditions
C++ Tutorial("Hello World")
Why hello everyone I'm just going to cut the crap and start the guide.
Well today I am going to show you how to get Codeblocks and make your first console Application.//
The first step is installing Codeblocks: HERE
Installing it just do: Next->I Agree->Next->Install and allow it to Install
One it is done installing it's time to launch Codeblocks... So launch it :p
-Once you launch it goto File->New->File...
-Choose C/C++ Source and click Next until you get to naming it.
-Click on the "..." button and name the file main.cpp and save it to your Desktop.
-It should then open up main.cpp now time for the coding part xD.
Programming Section(explanation):
<pre>#include <iostream></pre> - The "#include" part of the line is including the library "<iostream>". The "<iostream>" part is a header file which is used for input/output in the C++ programming language.
<pre>using namespace std;</pre> - keeps you from having to type std::cout each time you want to display a output on the console it always ends with a ";".
<pre>int main()</pre> - his line corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their execution.
<pre>{</pre> - Starting bracket for the main code.
<pre>cout << "Hello World";</pre> - 'cout << "" ' takes the text which is contained in the ""and outputs it on the console screen. it end's with a ";".
<pre>return 0;</pre> - The "return" statement causes the main function to finish. return may be followed by a return code.It is followed by the return code with a value of zero.
<pre>}</pre> - The end bracket finishes the main code.
Full Code for Newbs:
<pre>#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}</pre>
Then just Build&Run it.
EOSERV Wiki > Page: C plus plus Guide Hello World > History > Revision Diff