In this tutorial we take a look at character sequences using arrays.
We already know that the C++ Standard Library (STL) implements a powerful string class. The string class can be used to manipulate strings of characters. But it is also possible to use plain arrays of char elements to represent a string. (Strings are in fact a sequence of characters.)
We can do the following: More »
Posted in C++ Tutorials |
In this tutorial, we are going to talk about arrays.
An array lets you declare and work with a collection of values of the same type. Let’s say you want to declare four integers. With the knowledge from the last few tutorials you would do something like this: More »
Posted in C++ Tutorials |
In this C++ programming tutorial we will talk some more about functions. We also will take a look at command-line parameters and function prototypes.
Command-line parameters
In some cases you want to give a parameter at the start of a program. For example: More »
Posted in C++ Tutorials |
Most languages allow you to create functions of some sort. Functions are used to break up large programs into named sections.
You have already been using a function which is the main function. Functions are often used when the same piece of code has to run multiple times. In this case you can put this piece of code in a function and give that function a name.
When the piece of code is required you just have to call the function by its name. (So you only have to type the piece of code once).
Let’s take a look at a simple example: More »
Posted in C++ Tutorials |
In this C++ programming tutorial we will look at loops.
There are circumstances were you want to do the same thing many times. For instance you want to
print the same words ten times. You could type ten cout statements, but it is easier to use a loop, such as a “for loop” or a “while loop.” The only thing you have to do is to setup a loop that execute the same cout statement ten times.
There are three basic types of loops which are: More »
Posted in C++ Tutorials |
In this C++ programming tutorial we take a look at the “if statement” and “switch statement”. Both are used to alter the flow of a program (if the specified test condition is true).
The if statement
The if statement can be used to test conditions so that we can alter the flow of a program. In other words: if a specific statement is true, execute some instructions. If not true, execute these instructions. More »
Posted in C++ Tutorials |
In this tutorial we take a look at standard I/O and strings. The string statements used in this tutorial are basic. Later on we will take another look at strings. (We first need to explain some other topics like: control loops, pointers, etc).
cin and strings
In the last tutorial we already covered the use of cin and cout. Let’s take another look at a cin and cout example: More »
Posted in C++ Tutorials |
In this tutorial we will take a look at basic input and output. Using the C++ iostream library we will get the user’s input from the keyboard and we will print messages onto the screen. The iostream library is part of the C++ standard library.
In C++, I/O is performed by using streams. A stream is a “stream of data” in which character sequences are “flow into” or “flow out off.” A stream is an object with properties that are defined by a class. Global objects are predefined for the standard I/O channels. More »
Posted in C++ Tutorials |
Now we know how to use variables and constants, we can begin to use them with operators. Operators are integrated in the C++ language. The C++ operators are mostly made out of signs (some language use keywords instead.)
Assignment
We used this operator before and it should already be known to you. For the people that didn’t read the previous tutorials we will give a short description. More »
Posted in C++ Tutorials |
In this tutorial we will take a look at constants and escape codes. We will also introduce strings.
Constants
The difference between variables and constants is that variables can change their value at any time but constants can never change their value. (The constants value is locked for the duration of the program.)
Constants can be very useful, PI for instance is a good example to declare as a constant. More »
Posted in C++ Tutorials |