Journey of a C Program to Linux Executable in 4 Stages

You write a C program, use gcc to compile it. and you get an executable? It is pretty simple. Right?

Have you ever wondered what happens during the compilation process and how the C program gets converted to an executable?

There are four main stages through which a source code passed in order to finally become an executable.
Tiếp tục đọc

C – Variable

Sometimes, you may come across  a situation, when you want to have a function which can take a variable number of arguments,i.e., parameters, instead of a predefined number of parameters. The C programming language provides a solution for this situation and you are allowed to define a function which can accept a variable number of parameters based on your requirement. The following example shows the definition of such a function.
Tiếp tục đọc

How to Detect Memory Leaks Using Valgrind memcheck Tool for C/C++

One major aspect of system programming is to handle memory related issues effectively. The more you work close to the system, the more memory related issues you need to face.

Sometimes these issues are very trivial while many times it becomes a nightmare to debug memory related issues. So, as a practice many tool are used for debugging memory related issues.

In this article, we’ll discuss the most popular open source memory management framework VALGRIND.
Tiếp tục đọc

Buffer Overflow Attack Explained with a C Program Example

Buffer overflow attack has been there for a long time. It still exist today partly because of programmers carelessness while writing a code. The reason I said “partly” because sometimes a well-written code can be exploited with buffer overflow attacks, as it also depends upon the dedication and intelligence level of the attacker.

The least we can do is to avoid writing bad code that gives a chance to even script kiddies to attack your program and exploit it.
Tiếp tục đọc

How to Use C Structures, Unions and Bit Fields with Examples

Structures, Unions, and Bit fields are some of the important aspects of C programming language.

While structures are widely used, union and bit fields are comparatively less used but that does not undermine their importance.

In this tutorial, we’ll explain the concept of the structures, union and bit fields in C language using examples.

1. Structures in C

Structures provide a way to store multiple variables of similar or different types under one umbrella. This makes information more packaged and program more modular as different variables referring to different values can be accessed through a single structure object.
Tiếp tục đọc