C Circular Linked Lists

In this tutorial you will learn about C Programming – What is Circular Linked List, Adding Nodes to Circular Linked Lists, Traversing a Circularly Linked List and working with Circularly Linked List Example. Circular linked lists are usually used for a queue or stack type situation, or for implementing a round robin algorithm in system level programming. You could also use one for a multiplayer game where you were keeping track of player’s turns where it just repeats until the game ends. They are exactly the same as a singly… Read More

C Doubly Linked Lists

In this tutorial you will learn about C Programming – What is Doubly linked lists, Adding Nodes Doubly linked lists, Traversing a Doubly linked lists and working with Doubly linked list Example. Doubly linked lists are the same as singly linked lists, except they have an extra pointer per node so they point to the next node and the previous node. You just make sure that whenever you insert a node you set next to the next node and previous to the previous node. They will also commonly keep a… Read More

Call by Value and Call by Reference

In C programming language, variables can be referred differently depending on the context. For example, if you are writing a program for a low memory system, you may want to avoid copying larger sized types such as structs and arrays when passing them to functions. On the other hand, with data types like integers, there is no point in passing by reference when a pointer to an integer is the same size in memory as an integer itself. Now, let us learn how variables can be passed in a C… Read More

C Programming – Dynamic Memory allocation

Embedded and other low-memory footprint applications need to be easy on the amount of memory they use when executing.  In such scenarios, statically sized data types and data structures just are not going to solve your problem.  The best way to achieve this is by allocation of memory for variables at runtime under your watchful eye. This way your program is not using more memory than it has to at any given time. However, it is important to note that the amount of memory that can be allocated by a call… Read More

C Programming – Pointers

Pointers are widely used in programming; they are used to refer to memory location of another variable without using variable identifier itself. They are mainly used in linked lists and call by reference functions. Diagram 1 illustrates the idea of pointers. As you can see below; Yptr is pointing to memory address 100. Diagram 1: 1. Pointer and memory relationship Pointer Declaration Declaring pointers can be very confusing and difficult at times (working with structures and pointer to pointers). To declare pointer variable we need to use * operator (indirection/dereferencing… Read More

C Programming – Structures and Unions

In this tutorial you will learn about C Programming – Structures and Unions, initializing structure, assigning values to members, functions and structures, passing structure to functions, passing entire function to functions, arrays of structure, structure within a structure and union. Structures are slightly different from the variable types you have been using till now. Structures are data types by themselves. When you define a structure or union, you are creating a custom data type. Structures Structures in C are used to encapsulate, or group together different data into one object.… Read More

C Programming – Functions (Part-I)

The concept of functions in C language is the same as for any other programming language. Few languages have methods but, since there are no classes in C, methods are not used. Functions are best used for reusable code, or code that you know works and do want make use of it throughout development. If you find yourself tempted to use copy and paste on a particular block of code, even once, then you should move the code into a function. Lets talk about the different types of variables before… Read More

C Programming – Functions (Part-II)

Types of Functions You may have noticed the discussion about the <data type> portion of the function declaration missing from the last section. The <data type> refers to the type of data that would be returned by the function when it finishes executing. Data types are the same as any variable data types plus another one called void. Void type functions do not return any values. Function with no arguments and no return value: void function_name(); Think of this as a self-contained block of reusable code that does not need… Read More

C Programming – Handling of Character String

In this tutorial you will learn about Initializing Strings, Reading Strings from the terminal, Writing strings to screen, Arithmetic operations on characters, String operations (string.h), Strlen() function, strcat() function, strcmp function, strcmpi() function, strcpy() function, strlwr () function, strrev() function and strupr() function. In C language, strings are stored in an array of char type along with the null terminating character "\0" at the end. In other words to create a string in C you create an array of chars and set each element in the array to a char… Read More

C Programming – Arrays

Array is a collection of same type elements under the same variable identifier referenced by index number. Arrays are widely used within programming for different purposes such as sorting, searching and etc. Arrays allow you to store a group of data of a single type.  Arrays are efficient and useful for performing operations . You can use them to store a set of high scores in a video game, a 2 dimensional map layout, or store the coordinates of a multi-dimensional matrix for linear algebra calculations. Arrays are of two… Read More

C Programming – Managing Input and Output Operations

Input Output operations are useful for program that interact with user, take input from the user and print messages. The standard library for input output operations used in C is stdlib. When working with input and output in C there are two important streams: standard input and standard output. Standard input or stdin is a data stream for taking input from devices such as the keyboard. Standard output or stdout is a data stream for sending output to a device such as a monitor console. To use input and output… Read More