C++ - STL (Standard Template Library) - Using the vector container

The vector container is the most classic STL container.

In the snippet below, I can iterate through the vector, so I use an iterator to erase an element of the vector.
In our case, I removed the number 2 from the container and I added 80 to this place.

Let's see this example of the vector container.

C++ - Standard library - Using the pair container

The pair container cannot be iterated.

So we can use for example to return a double value at the end of a function.

In the snippet below we are going to use it to change the first and the second value.
This, respectively with the pair.first and pair.second methods:

 

C++ - STL (Standard Template Library) - Using the queue container

We are going to see in this queue tutorial, how to use it.

Let's see it with this first snippet.
In the easy example below, we add 10 elements in the queue before displaying its content.
We have to notice that we cannot iterate through a queue.

UNIX & GNU/Linux - System calls - Using gettimeofday()

The system call function gettimeofday() is a really helpful one.

Indeed, we can retrieve milliseconds of the time.

But in this tutorial, we are going to see how to generate random numbers every millisecond.

Here the code:

C - SDL (Simple Directmedia Layer) - Creating a multicolored window

May you want to create a night club with the SDL library?

It is maybe possible.
With the code below of this tutorial, you can generate a different color every millisecond.

So, why waiting?
Let's dance!

C - SDL (Simple Directmedia Layer) - Creating a rectangle and moving it

We are going to see, with this tutorial, how to create a shape on a window and how to move it with keyboard arrows.

We need, for this example, three files that we are going to create to dispatch the code:

UNIX & GNU/Linux - System calls - Using semget()

Today a tutorial to learn how to use semget(), semctl() and semop() system calls.

C - Library functions - Using srand() and rand()

Today a tiny tutorial to see how using srand() and rand() from the libc.

We will generate a number in a range between 0 and 2.
For that, we will use the functions:

Eclipse - Errors - While coding

This section will gather all errors found when you were coding in Eclipse.
It is really hard sometimes to find what is the problem when you get an exception.

I will also give a solution of the problem.

C - Errors - Handling errors

In this tutorial we will how to easily manage errors in C programming language.

That is we will try to open a file and if this file doesn't exist we will trigger an error.
If the file exists, we will tell its name with a message to say that the file really exist.

Pages

Subscribe to BadproG.com RSS