Pointer arithmetic is another name for address arithmetic. A pointer is moved by a multiple of the size of the data type it points to when it is added or subtracted from. Consider the following scenario: we have a pointer to a 4-byte integer array. This pointer's value will be increased by 4 by incrementing it (the size of the element).
When a pointer is incremented, the size of the data type for which it is a pointer is increased by the same number. For example, if an integer pointer that holds address 1000 is incremented, the new address will be 1002, and the new address will be 2(size of an int).
The following are the only allowed arithmetic operations on pointers: Addition of integers to a pointer. Integer subtraction from a pointer. Taking the difference between two pointers of the same type.
When you need to get a pointer back, you normally utilise pointer arithmetic. To retrieve a pointer with an array index, you must first calculate the pointer offset, then get the value at that memory position, and finally use & to get the address back. There will be more typing and less crisp syntax as a result of this.
On the pointers, we can do arithmetic operations such as addition, subtraction, and so on. However, because the address is stored in the pointer, the result of an arithmetic operation on the pointer will also be a pointer if the other operand is of type integer.
Learner's Ratings
4.4
Overall Rating
69%
18%
5%
4%
4%
Reviews
P
Pradeep Kumar Maurya
5
the world best course
M
Manmohan Surajlal Agade
5
good
A
Aakash Kumar
5
nice teacher
A
Ashlesh Satpute
5
Nice
S
SATYAM
5
this is a awosome course every boudy do it
B
Balaji Bhokare
5
nice
A
Ashish Arjun Gaikwad
5
Absolutely!!!and very easy to understand
Kolhapuri bhashet lay bhari...
Share a personalized message with your friends.