Moving along array element by Using Pointer Arithmetic - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Moving along array element by Using Pointer Arithmetic

Demo Code

#include <iostream> 

using namespace std; 

int main() /*from w w  w .  j  a  va 2s.com*/
{ 
    int Numbers[100]; 

    for (int i=0; i<100; i++) 
    { 
        Numbers[i] = i * 10; 
    } 

    int *cur; 
    cur = Numbers; 

    cout << *cur << endl; 
    cur++; 
    cout << *cur << endl; 
    cur++; 
    cout << *cur << endl; 
    cur += 3; 
    cout << *cur << endl; 
    cur--; 
    cout << *cur << endl; 

    return 0; 
}

Result


Related Tutorials