Associativity of Operators in C Programming

When some expression in C contains two operators with same/equal priority, the expression gets executed as per the “Associativity of Operators”, Check below program to understand, why it prints the results as “5” and not “1” $ vim associtivity_in_c.c $ gcc -o associtivity_in_c associtivity_in_c.c $ ./associtivity_in_c This program will display result as 5. Associativity of … Read more

Understanding gcc compilation steps : Linux compilation steps

Copy paste the below shell script and execute on your terminal. $ vim Copy below highlighted code and run the script as, $ bash ————- code start ——————— #!/bin/bash echo “ For any given input file, the file name suffix determines what kind of compilation is done: file.c C source code that must … Read more

Detect memory leaks using Valgrind in Linux

Valgrind is an instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools. We will need to install valgrind for ubuntu, $ sudo apt-get install valgrind Reading package lists… … Read more

Using electric fence for debugging memory leaks in Linux

Create a test program which has some memory leaks for understanding how to debug memory leaks with electric fence, $ vim efence.c Now, we will need to install electric-fence package on ubuntu as, $ sudo apt-get install electric-fence Reading package lists… Done Building dependency tree Reading state information… Done The following NEW packages will be … Read more

c program for creating a text file from string in buffer

Create a str_to_file.c file as contents below, OR use from github Compile above source as, $ gcc -o str_to_file str_to_file.c Test / Execute it as, $ ./str_to_file This will create myfile.txt in your current working directory where you have str_to_file binary, The code is also available at github

How to implement stack in C programming ?

In continuation of demonstrating simple implementation of data structures, as we shown in our last post “How to implement linked list in C programming ?”, in this post we will show how you can implement simple stack in C programming language. Stack is nothing but a one this kept on another, where we define how … Read more

How to implement linked list in C programming ?

This programs shows a simple way to implement singly link list ( Singly link list is the list which can be traversed only in one direction i.e. forward till end ) $ vim simple_linked_list.c The above program is self explanatory which initialises the head element of the linked list, adds more nodes into the linked … Read more