30 Aug 2016
School
Department
Course
Professor

POINTERS
#include <iostream>
using namespace std;
int main(){
//declaration
int a; //creates a space in RAM for a
//lets say a has an address called 1195
int *pa; //pa is a variable of type pointer to int
//initialize
a = 10;
inside the red box is 10, the value of a and the address of 10 in the memory is 1195
// Just to know *pa and a are the same thing. *pa = 10, a = 10, pa = address
pa = &a; //pa is equal to address of a, find the address of a and put it into pa
//process
//....
//....
//....
//print
cout << "The value of a is " << a <<endl; //Output 10
cout << "The value of a is " << *pa <<endl;//i want to print the value of where pa points to
//Output 10;
cout << "The address of a is " << pa <<endl;//Output 1195
return 0;
}
find more resources at oneclass.com
find more resources at oneclass.com