20120113

How to learn Pointers in C++

Program in c to learn pointer in C,pointer2.cpp

#include<iostream>
using namespace std;
int main()
{
int a=10;
int *ptr1, **ptr2; //note thatptr2 is ptr to ptr
ptr1=&a;
ptr2=&ptr1;
cout<<"Value of a is : \n"<<a<<"\n";
cout<<"Value of a is : \n"<<*ptr1<<"\n";

cout<<"Manipulating the value of contained by pointer \n";
*ptr1=(*ptr1)/2;
cout<<"Value of a is : \n"<<a<<"\n";
cout<<"Value of a is : \n"<<*ptr1<<"\n";
//cout<<"Adress of a is : \n"<<ptr1<<"\n";
//cout<<"Address of ptr1 is: \n"<<ptr2<<"\n";
return 0;
}

Previous                             Home                               Next

3 comments:

  1. How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C

    ReplyDelete
    Replies
    1. How to use pointers in C++ cpp C
      How to use pointers in C++ cpp C
      How to use pointers in C++ cpp C
      How to use pointers in C++ cpp C
      How to use pointers in C++ cpp C
      How to use pointers in C++ cpp C
      How to use pointers in C++ cpp C
      How to use pointers in C++ cpp C

      Delete
  2. How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C
    How to use pointers in C++ cpp C

    ReplyDelete