C pointer arithmetic operationsPritesh
Consider below table, We have declared some of the variables and also assumed some address for declared variables.
|Data Type||Initial Address||Operation||Address after Operations||Required Bytes|
We can see address of an variable after performing arithmetic operations.
|Address + Number||Address|
|Address – Number||Address|
|Address – Address||Number|
|Address + Address||Illegal|
Above table clearly shows that we can add or subtract address and integer number to get valid address. We can even subtract two addresses but we cannot add two addresses. Here are some pointer tutorials on Arithmetic Operations –
|1||Pointer Arithmetic : Incrementing Pointer||Click Here|
|2||Pointer Arithmetic : Decrementing Pointer||Click Here|
|3||Pointer Arithmetic : Addition of Pointer and Number||Click Here|
|4||Pointer Arithmetic : Subtraction of Pointer and Number||Click Here|
|5||Pointer Arithmetic : Differencing between two pointers||Click Here|
|6||Pointer Arithmetic : Comparing two Popinters||Click Here|