- Joined
- Aug 5, 2009
- Messages
- 1,403
- Reaction score
- 164
Welcome to my first C++ Turtorial!
What is C, What is C++, and What is the Difference?
C is a programming language originally developed for developing the Unix operating system. It is a low-level and powerful language, but it lacks many modern and useful constructs. C++ is a newer language, based on C, that adds many more modern programming language features that make it easier to program than C.
Basically, C++ maintains all aspects of the C language, while providing new features to programmers that make it easier to write useful and sophisticated programs.
For example, C++ makes it easier to manage memory and adds several features to allow "object-oriented" programming and "generic" programming. Basically, it makes it easier for programmers to stop thinking about the nitty-gritty details of how the machine works and think about the problems they are trying to solve.
So, what is C++ used for?
C++ is a powerful general-purpose programming language. It can be used to create small programs or large applications. It can be used to make CGI scripts or console-only DOS programs. C++ allows you to create programs to do almost anything you need to do. The creator of C++, Bjarne Stroustrup, has put together a partial list of applications written in C++.
To program C++ you'll need a complier. A compiler converts source code - the actual instructions typed by the programmer - into an executable file. Numerous compilers are available for C and C++. Listed on the sidebar are several pages with information on specific compilers.
Thanks cplusplus.com for this nice intro
Here's the C++ i would personally suggest.
1. Download Visual Basic 2008
2. Download Eclipse
3. Download Codeblocks
4. Download Codewarrior
5. Download Dev-C++
All these are compliers.
When you've downloaded your complier, you'll need to create a new project. Click
File > New Project
Win32 Console Application [x]
Choose a name for your project.
[Empty project]
Right click on your project, at the left menu bar.
Click Add > New > [C++ file] Click OK.
Lets get started with the coding!
Text input!
PHP:
#include <iostream> // This is a library you'll need to display text
using namespace std; // Let's you acces your library for c++ .
int main() // This is our main function.
{ // Open bracket. Inside the brackets is where the magic stuff happends.
cout<<" Hello Ragezone" <<endl; // Cout is the function which displays the text and 'endl is EndLine, what it does is jumps down a line. The '' ; '' ends a statment.
cin.get(); // If we would'nt add this it would terminate the program after the text have appear cus the program has nothing left to do
} // End bracket
This is what it will look like when your done [Complie & run]
Code 2
User input!
PHP:
#include <iostream>
using namespace std;
int main()
{
int number; // Variable function name
cout<<"Please enter a number: "; // Number: allows you to type something into the program
cin>> number; // The first statement declares a variable of type int called number, and the second one waits for an input from cin (the keyboard) in order to store it in this integer variable.
cin.ignore(); //this is another function that reads and discards a character
cout<<"You entered: " <<number <<"\n"; // " <<number <<" shows what number(s) you type'd before. ( \n ) Is another way to jumpdown a line
cin.get();
}
This is what it will look like when its done [Complie & run]
This is the end of C++ turtorial part one. The next turtorial i'll write will be about
If statments and loops. Before you read my next guide, practise with this and play around with the codes .
Hope you like my turtorial, if you do Thank me if you'd like!
Other turtorials for beginners:
http://www.cprogramming.com/begin.html
http://www.howtoforge.com/beginners_guide_to_cplusplus
http://cpp-tutorial.cpp4u.com/
Last edited by a moderator: