Advanced C Pointer Programming chapter 8: Pointers and functions

Functions are building blocks of C programming language. In this chapter we shall see different ways to pass pointers to a function. We shall concentrate on 2 aspects. 1. Sending pointers to a function 2. Returning pointers from a function. Passing variable by pointer This type of passing is also called as pass by value. […]

Advanced C Pointer Programming chapter 7: Pointers and Structures.

In C, after arrays, structures are the most important data structure available for programmers. We shall understand different ways to initialize memory to structure and accessing elements inside a structure. Creating simple structure and accessing elements inside them In this example, we shall create a structure variable inside main and allocate memory in stack. Below […]

Advanced C Pointer Programming chapter 6: Pointers and Strings.

There is no separate data type in C to hold strings. In C, strings are character array. They should always end with NULL “\0” character. While allocating memory for strings, space should be allocated for NULL character also. C allows us to create a static strings or dynamic strings using pointers. We usually send C […]

Advanced C Pointer Programming chapter 5: Pointers and Arrays.

Before we understand the relationship between pointers and arrays, let us see some basic examples of arrays. Statically allocated arrays The size of the array known at compile time is called as statically allocated arrays. The memory will be given in the program stack. They are stored in contiguous memory locations. Hence you can do […]

Advanced C Pointer Programming chapter 4: Function pointers.

A function pointer is a pointer that holds the memory address of a function. How to declare a function pointer in C? Consider the function prototype as below: void sum (); According to the above function prototype, the function sum will not take any arguments, and will not return anything. So we can declare a […]

Advanced C Pointer Programming chapter 3: Pointers and Dynamic Memory Management.

Dynamic Memory Management Introduction. C provides a way to allocate memory at runtime. This is done with the help of DMM. This is a very important feature in C language, and yet programmers seldom makes mistake while writing a program resulting in program crash. Different types of Dynamic Memory Allocation functions There are 3 different […]

Advanced C Pointer Programming chapter 2: Pointer Arithmetic

Introduction: Operations that can be performed on Addresses: WKT pointer variable will hold the address of another variable. i.e int a = 10; int *ptr = NULL; ptr = &a; Now, If you print “ptr”, it will print the value that is stored inside it. i.e the address of variable a. If you print “*ptr”, […]

Advanced C Pointer Programming chapter 1: Introduction to pointers

Pointers in C is a very interesting topic if understand correctly. Hence in this series of Advanced C Pointer Programming tutorial I shall make you understand pointer in a simple and easy. The only prerequisite is that you should be knowing the basic syntax of C programming. In each chapter beginning I shall be giving […]

C Language Dynamic Memory Allocation.

In this lesson we shall study about following topics 1. Introduction 2. Malloc 3. Calloc 4. Re-alloc 5. Free 1. Introduction  In C program there are 2 ways to allocate memory. 1. Compile time memory allocation: We use this type of allocation when we know the size of elements that we are storing before execution […]

C language file operations

In this chapter we shall study about below topics: 1. Introduction 2. Common file functions 3. Basic file operation functions 4. File open modes 5. Binary Modes 6. File Input and Output operations 1. Introduction A file is a sequence of bytes that are stored in the secondary memory. There are various kinds of files, […]