Sunday, February 19, 2017

Pointer Address in C++

A simple program that I wrote a long time ago in C++ that shows how to use pointers to know the memory address of the variable. The code is very short and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>

using namespace std;

main() {
    int value = 10;

    int *ptrvalue;

    ptrvalue = &value;

    cout << "The original value is " << value;
    cout << "\n\n";
    *ptrvalue = 20;
    cout << "The new value is " << value;

    cout << "\n\n";
    system("PAUSE");
}

No comments:

Post a Comment