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

Programing solution, write a program that declares and initializes 2 intege...

write a program that declares and initializes 2 integer variable a and b with the value 35 and 14, and displays and calculates their sum,product,quotient and real division result.t

Hwid spoofer for windows 7, HWID Spoofer for Windows 7, 8 x64 Project De...

HWID Spoofer for Windows 7, 8 x64 Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program a

I want application to generate premium, Project Description: We want to ...

Project Description: We want to generate premium numbers for one of our application. What we need is: A program that generate 2, 3, 4, 5, 6, 7, 8 digits premium numbers

What is namespace and explicit container, What is Namespace and Explicit ...

What is Namespace and Explicit container Namespace - Namespaces are used to group entities such as objects, classes and functions under a name. Explicit container.

Prepare an ipad application clash of clans like game, Prepare an iPad appli...

Prepare an iPad application Clash of Clans like game I would like to prepare a free city building app with the in app purchase possibility. An example game could be Clash of Cla

Applied scientific computing in c++, i have a project that is due this Wedn...

i have a project that is due this Wednesday and i was wondering if i can get help in doing it?

Search property from catalogue , Implement the search property from catalo...

Implement the search property from catalogue menu option.  After selecting this option the user should be asked to specify the property using the following sub-menu: 1. Specif

When i throw this object, A: Depends. Might be "zero" Objects which are ...

A: Depends. Might be "zero" Objects which are thrown must have a publicly accessible copy-constructor. The compiler is permitted to generate code which copies the thrown object

C program for sorting of long word with different string, C Program for SOR...

C Program for SORTING OF LONG WORD WITH DIFFERENT STRING #include stdio.h> #include conio.h> #include string.h>   void main() {           char n[50],c[25][25]

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