SHOP FOR NEW ARRIVALS NOW!
FREE doorstep delivery \$100 (worth \$10)
Receive park discount voucher (\$2 off) with every purchase

The formula of decrementing the pointer is given below: For 32-bit int variable, it will be decremented by 2 bytes. As you understood pointer is an address which is a numeric value; therefore, you can perform arithmetic operations on a pointer just as you can a numeric value. This operation will move the pointer to next memory location without impacting actual value at the memory location. Please mail your requirement at [email protected] We prefer using a pointer in our program instead of an array because the variable pointer can be incremented, unlike the array name which cannot be incremented because it is a constant pointer. If ptr points to a character whose address is 1000, then above operation will point to the location 1001 because next character will be available at 1001. Consider the following example. Like increment, we can decrement a pointer variable. Duration: 1 week to 2 week. As we discussed in the previous chapter, a pointer can point to a function in C. However, the declaration of the pointer variable must be the same as the function. Therefore, you can perform arithmetic operations on a pointer just as you can on a numeric value. Let's see the example of adding value to pointer variable on 64-bit architecture. en.

However, as we know that pointer contains the address, the result of an arithmetic operation performed on the pointer will also be a pointer if the other operand is of type integer. The formula of adding value to pointer is given below: For 32-bit int variable, it will add 2 * number. As you can see, the address of p is 3214864300. For 64-bit int variable, it will add 4 * number. For 32-bit int variable, it will be incremented by 2 bytes. You can see after subtracting 3 from the pointer variable, it is 12 (4*3) less than the previous address value.

Assuming 32-bit integers, let us perform the following arithmetic operation on the pointer −. Mail us on [email protected], to get more information about given services. In other words, the pointer to an array of functions is a pointer pointing to an array which contains the pointers to the functions. JavaTpoint offers too many high quality services.

Assuming 32-bit integers, let us perform the following arithmetic operation on the pointer − We can perform arithmetic operations on the pointers like addition, subtraction, etc.

It will not be a simple arithmetic operation, but it will follow the following rule. A list of such operations is given below.