What is pointer arithmetic, C/C++ Programming

Assignment Help:

Pointer Arithmetic

We can manipulate the pointers too. We can perform operations such as addition, subtraction, increment and decrement etc.,. As the pointer variables have address, adding or subtracting a number results in another address, which is at an offset from the original address. This may be memory address occupied by another variable.

e.g.

                int   i, j, k ;

                int  *iptr = &i;

                *iptr = *iptr + 2;  // I = I + 2;

                 iptr = iptr + 2 // adds 2 to address.

These are useful when using arrays.

e.g.

arr[10];

int *iptrb = &arr[0];

int *iptre = &arr[10];

While ( iptrb != iptre)

     {        

 Do something with the value if (*iptrb);

++iptrb;

}

 


Related Discussions:- What is pointer arithmetic

Merge sort, Write a program in C language to implement Two-Way Merge Sort. ...

Write a program in C language to implement Two-Way Merge Sort. Input the following data to the program. Show all intermediate steps: 84, 83, 78,90,23,123,98,159,8,200

[email protected], Write a program to find the area under the curve y =...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

C program to convert number to binary, Write a program in C that you will n...

Write a program in C that you will name "divide.exe", to divide one 32-bit twos-complement binary number by another, giving the quotient and the remainder, using the subtract-shift

Simple object-oriented program, This assignment is to be undertaken individ...

This assignment is to be undertaken individually - no group work is permitted. Background information This assignment is an exercise in simple object-oriented programming and, acco

How many non-boundary pits and peaks are on the map, Armed with your functi...

Armed with your function from above, we can do some interesting things. For instance, any pixel where the offsets are both zero is a pit (lower than all surrounding points) .

What are control structures, What are control structures? - Control str...

What are control structures? - Control structures decide which instructions in program must be executed. - This implies that program flow may not necessarily move from one s

What is an explicit constructor, A conversion constructor declared with the...

A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to execute an implied conversion of types. Its purpose is reserved ex

Area under Curve, #queWrite a program to find the area under the curve y = ...

#queWrite a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points c

Demonstration using moss open source machine translation, Demonstration usi...

Demonstration using Moss Open Source Machine Translation Project Description: Moses is an open source Statistical Machine Translation System. I need someone to provide me a d

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd