Tutorial By: Retribution
Program: Dev-C++
Language: C++
Difficulty: * (Out of Five Stars)
The Code we will make:
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
cin.get();
return 0;
}
Part One: How to StartSo you want to start programming C++ but don't know were to start? In Part One I will teach you on how to start programming.
C++ if different than web coding like most of you probably know or tried. In C++ it doesn't need starting tags. (Example: <script></script>, <html></html>, <?php ?>, etc) Also it needs a compiler to make the code into a program. Every Compiler is different, they have their own tools, and coding that they can understand. One thing that is good is all compilers can understand all kinds of code just by entering libraries into your code, which we will go over later.
The Compiler I use:
Bloodshed or Dev-C++ Both are the same program, but called a different name (I mostly call it Dev-C++)
Part Two: Hello World!The easiest way, that I have found, to learn how to code is to cut the code down and tell what each part does. That is what I will do in my tutorials.
Code: Hello World!
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
cin.get();
return 0;
}
#include <iostream> = #include is a preprocessor that tells the program to include a code called iostream. Iostream is a library that is used for mostly all C++ coding.
using namespace std; = This is a statement that tells the compiler to use a group of functions from the std (Standard Library). Using this makes you able to use code like cout, which is used to write text. The semicolon is part of the C++ syntax that tells the compiler to end the statement.
int main() { = This means that there is a function named main and it returns as a integer. (int) The curly brackets tell the code that it is the beginning of a function.
cout << "Hello World!"; = Cout is what is used if you want to output text. After cout comes the two << signs. These are called "insertion operators" which tells the compiler what to output. All text that is going to be output have Quotes around it. After it all comes a semi colon which tells the code it is the end of the statement.
cin.get(); = cin.get(); is the same thing as system("PAUSE"); They make it so you have to press enter to exit out of the program. (without one of these your program will not start) The only different between the two is that cin.get(); will not enter any text into your program and with system("PAUSE"); it will put "Press Enter to Continue" so the people that are using your code will know to press enter to exit. (I use cin.get(); most of the time)
return 0; = This tells the compiler that there is no more code after this. Some compilers don't need this at the end but it makes your code look more professional
} = The last part of the code. it tells that it is the end of the main(); function. (we used a { to tell the beginning of the function so we have to use a } at the end)
Hopefully you can understand because I'm not good at writing
If you have questions or don't understand a part just ask.
Next Part: Variables and Condition Statements