C Q&A #5: A question about assignment operation and evaluation

Here is another C code snippet question. Consider the following piece of code, and spot if there is a problem in it or not.

#include <stdio.h>

int main (void)
  int x = 5;
  +x += 1;
  printf ("%d\n", +x);
  return 0;

Continue reading “C Q&A #5: A question about assignment operation and evaluation”

C Language Constructors and Destructors with GCC

Constructors and Destructors are special functions. These are one of the features provided by an Object Oriented Programming language. Constructors and Destructors are defined inside an object class. When an object is instantiated, ie. defined of or dynamically allocated of that class type, the Constructor function of that class is executed automatically. There might be many constructors of which the correct implementation is automatically selected by the compiler. When this object is destroyed or deallocated, the Destructor function is automatically executed. For example when the scope of the object has finished or the object was dynamically allocated and now being freed. The Constructors and the Destructors are generally contains initialization and cleanup codes respectively required by an object to operate correctly. Because these functions are automatically invoked by the compiler therefore the programmer freed from the headache of calling them manually.

Continue reading “C Language Constructors and Destructors with GCC”

Beginners Guide to GCC

GCC is the default compiler in the GNU+Linux systems, and is used to compile small applications, big softwares, and the kernel. Often beginners are overwhelmed with the amount of information provided in the gcc manual. This tutorial highlights the most useful commands and describes how to use them, how to read warnings and errors from the compiler output and compile the C Language sourcecodes with gcc. This tutorial does not cover advanced options and topics, in depth details are avoided. This tutorial will give the basic idea, and after reading this i hope that the manual pages would be easier to read.

Continue reading “Beginners Guide to GCC”