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

Text Editor, Add a function for saving the text stored in an array to a fil...

Add a function for saving the text stored in an array to a file. Your program must check whether or not the output file already exists, and if it does, your program must ask the us

Describe "this" pointer?, It is a pointer accessible only in the member fun...

It is a pointer accessible only in the member functions of a struct, class or union type. It points to the object for which the member function is called. Static member functions d

Super ASCII string cost, string will contain only lower case alphabet& the ...

string will contain only lower case alphabet& the ascii value starts from 1-26,(ie,a=1&z=26).it perform the operation like the following costs:add=2units,replace=1unit,delete=3unit

Program to create a class and store student information, Develop a Student ...

Develop a Student class that has the following header file: #ifndef STUDENT_H #define STUDENT_H #include #include #include using namespace std; class Stu

Assignmet, I have a assignment deadline is 11.11.2015 can I get help

I have a assignment deadline is 11.11.2015 can I get help

Palindorme, program coding for the conversion of string to a palindrome

program coding for the conversion of string to a palindrome

Develop banking software and payment gateway system, Project Description: ...

Project Description: 1) Develop banking software 2) Payment Gateway System There is some other system available for development. I'm willing to show long-term opportunity

PROGRAM, TO CONVERT A NUMBER OR A DIGIT INTO ALPHABET

TO CONVERT A NUMBER OR A DIGIT INTO ALPHABET

Write a program to illustrate array of structures, Write a program to illus...

Write a program to illustrate array of structures? struct customer { int id; char name[15]; }; struct customer c[100]; . In the above instance, the array of Structures is

Pointer declaration for class, P o i n t e r d e c l ...

P o i n t e r d e c l a r a t i o n f o r C l a s s : M m; M * p m; / / C la ss M i s d e c l a r e d a s

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