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
L
Lalita
5
this courses are very helpful. thank you so much.
B
Biwek Gorai
5
I like this course , thank you for your free courses, your free course many people for helpful.
S
SHAYAQ SHAFI
5
sir please provide pdf
Y
Yash Lohiya
5
I am really thanks to learnvern because they give best lectures without any cost sir please. I am really requesting please give us pdf
S
Sonu Kumar
5
teaching is really very awesome.
If assignment would be in the pdf along with lecture. then it would be more benificial.
A
ashish patil
5
Teaching is very best everything is understanding thank you so much 🙏
Share a personalized message with your friends.