Use a for statement to print the elements of array 'values' by subscripting the pointer to the array. - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Use a for statement to print the elements of array 'values' by subscripting the pointer to the array.

Demo Code

#include <iomanip>
#include <iostream>

int main(int argc, const char *argv[]) {
    const int SIZE = 5;
    unsigned int values[SIZE] = {2, 4, 6, 8, 10};
    unsigned int *vPtr;
    vPtr = values;/*  www . j  a  va 2 s . c  o m*/

    for (int i = 0; i < SIZE; ++i) {
        std::cout << std::setw(4) << vPtr[i];
    }
}

Result


Related Tutorials