..

FreePrograms


C programming Tutorial 

Free C Programs, C Programs Download


Embedded C lang & 8051(Embedded Products)


  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

 C Tutorial for beginners
What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming  Data Structures in C C interview Questions

/*Pointers in CPP   C++/CPP Tutorial.*/

 
In this pointers cpp program, we have assigned as value of mypointer a reference to firstvalue using the reference operator (&). And then we have assigned the value 5 to the memory location pointed by mypointer, that because at this moment is pointing to the memory location of firstvalue, this in fact modifies the value of firstvalue.


#include <iostream.h>
using namespace std;

int main ()
{
int firstvalue, secondvalue;
int * mypointer;


//
www.freecprograms.com pointers in cpp

mypointer = &firstvalue;
*mypointer = 5;
mypointer = &secondvalue;
*mypointer = 10;
cout << "firstvalue is " << firstvalue << endl;
cout << "secondvalue is " << secondvalue << endl;
return 0;
}

 

Output

firstvalue is 5

secondvalue is 10
 

 

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM