Archive for the “C/C++ Programming” Category

Handling exceptions in C++ is a quite easy, but pretty imporant procedure. You go even go about creating your own class that would handle exceptions locally. The idea is that you define your set of functions that checks for certain conditions and throw exceptions if they are not met. Basic exception handling usage involves using the try and catch commands. Inside the try block, you insert the code that you want to check for exceptions, while inside catch is the actual exception handling procedure. This is an example, handling a division by zero exception :

Read the rest of this entry »

Comments No Comments »

Threaded programming is a quite large programming topic on its own. However, little by little, we will get to know of pThreads better. For starters, we will be describing how to create a simple thread using pThreads. Doing so is pretty easy. We just need to use pthread_create() in order to create our new thread. Let’s take a look at the code needed to create a simple thread that just prints a Hello :

Read the rest of this entry »

Comments No Comments »

The assert macro is a very nice utility for programmers. It may sound complicated, but it is just a small macro that exits the program, giving us some debugging information on where the assertion happened, if a certain condition gets evaluated to false. Therefore :

Read the rest of this entry »

Comments No Comments »

C++ is all about making C programmers lives easier. Function overloading is one more C++ feature that presented a nice technique for writing better and more managed code.

Read the rest of this entry »

Comments 2 Comments »

C++This is a guest post by a good personal friend of mine under the name Black Shadow.

Whenever we need to fill in an array, multiply a variable against a value multiple times or generally want to do the same stuff over and over, we use the C++ looping structures. They help us repeat the commands that we want to execute. We specify a set of commands to be executed according to a certain condition that we also define. While this condition is evaluated as true, the set of commands keeps executing, while when it becomes false, the looping structure ends. In general, the checking condition of a looping structure consists of a counter, that counts the number of times that the set of commands was executed. There are 3 different looping structures :

Read the rest of this entry »

Comments No Comments »

C++Each C++ program contains at least one function, main(), which signifies the entry point of the program. Think of functions as procedures that execute certain tasks. Functions consist of parameters that actually are auxiliary variables for them. Moreover, they need to return a value, whether that is an integer or a void (meaning no value at all). Whenever we declare a function, its prototype must end with a greek question mark (;)

Read the rest of this entry »

Comments No Comments »