Using int pointer - C++ Data Type

C++ examples for Data Type:Pointer

Description

Using int pointer

Demo Code

#include <cstdlib> 
#include <iostream> 

using namespace std; 

int main(int argc, char *argv []) 
{ 
     int anInt = 5; 
     int *anIntPointer = &anInt; 

     cout << "anInt = " << anInt << endl; 
     cout << "*anIntPointer = " << *anIntPointer << endl; 
     cout << endl; //from  w w  w  .j a  v a2 s .c o  m

     *anIntPointer = 100; 

     cout << "anInt = " << anInt << endl; 
     cout << "*anIntPointer = " << *anIntPointer << endl; 
     cout << endl; 

     anInt = 50; 

     cout << "anInt = " << anInt << endl; 
     cout << "*anIntPointer = " << *anIntPointer << endl; 
     cout << endl; 

   
     return 0; 
}

Result


Related Tutorials