C++ Pointer Changes the value of a pointer variable

Description

C++ Pointer Changes the value of a pointer variable

#include <iostream>
using namespace std;
#include <iomanip.h>
void main()//from w ww.  j  a  v a 2s  .  c  o m
{
   float v1=123.54;                         
   float v2=900.18;            
   float * p_v;         
   p_v = &v1;           
   cout << "The first value is " << setprecision(2) << *p_v << "\n";                
   p_v = &v2;            
   cout << "The second value is " << setprecision(2) << *p_v << "\n";               
   return;
}



PreviousNext

Related