Point vPtr to values[4], what address is referenced by vPtr -= 4? What value is stored at that location? - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Point vPtr to values[4], what address is referenced by vPtr -= 4? What value is stored at that location?

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;/*from www.  j  a  v  a2  s. c o  m*/

    vPtr = &values[4];
    vPtr -= 4;

    std::cout << *vPtr << std::endl;

    return 0;
}

Result


Related Tutorials