Pointer to Arrays

Pointer to array and array to a pointer, both are totally different things. In this section, we are going to understand the pointer to an array. Actually, the name of the character array (string), itself is a pointer. Below lines will print the address of str string. Ex1. char str[10]=”abcdef”;         printf(“%u”,str);  //%u…

Pointer as return type of function

When any function is returning an address then the return data type of that function must be a pointer. Because returning value is an address, to store an address we need a pointer. In short, to hold an address we need a pointer so the function which returns the address needs a pointer variable to…

Generic and Null Pointer

In this session, we are going to understand the meaning & use of a generic and NULL pointer. Generic pointer (void pointer) The generic pointer is also called void pointer also. With pointer declaration, we have to specify its data type also. That data type is the same as the data type of that variable,…

Multiple Indirections

Multiple indirections are called pointer of pointer or chain of pointer. So how to make a chain of pointer and how to use it is explained below. Here we will learn up to two levels of a pointer. For more levels, we need more indirection operators to use. Syntax of declaring pointer of pointer Syntax…

Pointer Arithmetic

Pointer arithmetic means adding or subtracting values to the pointer variable. This is not the same as those simple arithmetic operations in normal variables. So how pointer arithmetic is different from simple arithmetic is explained below. Adding integer to pointer Suppose ‘p’ is a pointer to the ‘a’ variable. If we are adding n to…

Declaration and Assignment of Pointer

Now as we know meaning of & and * operators. We are going to declare and assign a pointer variable. Both are explained below. But the first most important thing about pointers is, “Data type of pointer and data type of variable (whose pointer we are creating) must be the same”. This means we want…

Pointer Address and Value

For pointers in C language, & and * operators are very important. To use a pointer, the understanding of both operators is a must. The meaning of both is as explained below. Meaning of & operator ‘&’ operator is called address operator. We can spell ‘&’ as “address of” whenever we are using it. This…

Introduction to Pointers

The C language is a very powerful language and its power is because of the pointer. With the right use of a pointer, we can make compact and very effective code using a pointer. The pointer is used for returning more than 1 value from any function, for DMA (Dynamic memory allocation), to access members…

Masking, Setting, Clearing and Testing of Bits

In the process of masking, we mask or filter bits of a variable. The variable is called the original value and the trail of bits that we are masking to the original value is called a mask. In this process, some bits of variables change and other bits remain as they are. We can do…

Shifting Operator

Left and Right operators are used to shift bits of a variable. First it converts that variable into its binary form and then shifts it to right or left. Using both operators, we can do multiplication and division of any variable with any number which is a power of 2. All these things we are…