c 2b 2b pointer arithmetic

Solutions on MaxInterview for c 2b 2b pointer arithmetic by the best coders in the world

showing results for - "c 2b 2b pointer arithmetic"
Manuel
13 Mar 2020
1#include <iostream>
2
3using namespace std;
4const int MAX = 3;
5
6int main () {
7   int  var[MAX] = {10, 100, 200};
8   int  *ptr;
9
10   // let us have array address in pointer.
11   ptr = var;
12   
13   for (int i = 0; i < MAX; i++) {
14      cout << "Address of var[" << i << "] = ";
15      cout << ptr << endl;
16
17      cout << "Value of var[" << i << "] = ";
18      cout << *ptr << endl;
19
20      // point to the next location
21      ptr++;
22   }
23   
24   return 0;
25}
Livvy
18 Jan 2019
1#include <stdio.h>
2
3const int MAX = 3;
4
5int main () {
6
7   int  var[] = {10, 100, 200};
8   int  i, *ptr;
9
10   /* let us have array address in pointer */
11   ptr = &var[MAX-1];
12	
13   for ( i = MAX; i > 0; i--) {
14
15      printf("Address of var[%d] = %x\n", i-1, ptr );
16      printf("Value of var[%d] = %d\n", i-1, *ptr );
17
18      /* move to the previous location */
19      ptr--;
20   }
21	
22   return 0;
23}
queries leading to this page
do c 2b 2b have pointer arithmeticc 2b 2b pointer arithmetichow to do pointer arithmetic c 2b 2bwhat are the pointer arithmetic operations allowed in c 2b 2bc 2b 2b arithmetic void pointerc 2b 2b pointer arithmetic c 2b 2bpointer arithmetic c 2b 2b examplespointer arithmetic in c 2b 2b examplepointer arithmetic in c 2b 2bpointer arithmetic c 2b 2bwhat is pointer arithmetic in c 2b 2boperations on addresses in cppc 2b 2b int function pointer pointer array address arithmetic in c 2b 2bdoes c 2b 2b use pointer arithmeticthis pointer addition in c 2b 2bpointer arithmetic in cpparithmetic operations on pointers in carithmetic of pointers in cpointer operationc pointer arithmeticarithmetic on pointers c 2b 2bpointer increment in c 2b 2bpointer arithmetic in ccpp pointer arithmeticbasic arithmetic operations using pointers carithmetic operators on pointers in c 2b 2bdo pointer arithmetic c 2b 2bpointer arithmetics in carithmetic operations in pointers in c 2b 2baddition pointer c 2b 2bc 2b 2b pointer arithmetivpointer arithmetic operations in cpointer arithmetic carithmetic operations used with pointers c 2b 2bpointer arithmeticc 2b 2b pointer additionpointers arithmetic c 2b 2bpointer arithmetic c pointer array address arithmetic in c 2bprogram for implementing pointer arithemetic in cppyou can use pointer arithmetic in cvoid arithmetic pointer c 2b 2bpointer arithmetic program in cwhat are pointer expression and arithmetic in c 2b 2bc 2b 2b pointer arithmetic with referencearithmetic operations on pointerswhat is pointer arithmetic c 2b 2bpointer addition c 2b 2barray arithmetic c 2b 2boperations allowed on pointers c 2b 2bc 2b 2b pointer arithmetic