pointers Getting started with pointers Getting Started with Pointers


Pointers are variables that store the address of another variable.As language feature they are available in several programming languages like, but not limited to :

  • Go
  • C/C++
  • Ada
  • Pascal
  • C# (available under certain constraints)

To get started with C/C++ pointers , follow these steps

  1. Install compiler like Minimalistic GNU for Windows, http://www.mingw.org/wiki/Getting_Started

  2. Go to the installation folder of g++ binary via commandline for example:


3.Create a text file and write this C++ program

#include <iostream>

int main () {

   int  pointed=0;
   int* ptr = & pointed;

   std::cout<<"Address of pointed variable is: "<<ptr<<std::endl;

   return 0;
  1. Save as pointer.cpp 5.On the command prompt run the command

g++ -o pointer.exe -c pointer.cpp

  1. In the working directory you will get a executable as pointer.exe , this exe upon running will give some output like

Address of pointed variable is: 0x7e892dac0a0c

If you receive the above output, you have written your first pointer program