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.
VERY USEFULL EXPERIENCE
Nirali K Patel
Superb and amazing 😍🤩 enjoyable experience.
Nice teaching sence... I like this platform..
Your teaching style is very very good.and simple.
It is a very good C programming language course. Yes it is.
best matarial in hindi medium student
that are very best ara learnig skill so that are the best of best
Share a personalized message with your friends.