Refer to the 5th element of 'values' using array subscript notation, pointer/offset notation with the array name as the pointer. - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Refer to the 5th element of 'values' using array subscript notation, pointer/offset notation with the array name as the pointer.

Demo Code

#include <iomanip>
#include <iostream>

int main(int argc, const char *argv[]) {
    const int SIZE = 6;
    unsigned int values[SIZE] = {2, 4, 6, 8, 10, 12};
    unsigned int *vPtr;
    vPtr = values;/*from   w ww  .  java2s.  co m*/


    int a = values[4];
    a = *(values + 4);
    
    std::cout << a;

}

Result


Related Tutorials