arrow
arrow

Pointers

basic code of a pointers


                            
#include<iostream>
using namespace std;
int main()
{
    int a=5;
    int *p;
    p=&a;
    //& is a refernce operator
    //* is a derefernce operator
    cout<<a<<endl;//Original value of a
    cout<<p<<endl;//reference (address) of a
    cout << &a << endl; // reference (address) of a
    cout << *p << endl; // Original value of a
    return 0;
}
                                    
                            
                        

Double Pointers


                        
#include <iostream>
using namespace std;
int main()
{
    int a = 5;
    int *p;
    p = &a;
    int **ptr;
    ptr=&p;
    cout << p << endl; // Original value of p as a address stored in p
    cout << ptr << endl; // reference (address) of p as a address of a pointer varibel p

    cout << &p << endl; // reference (address) of p as a address of a pointer varibel p
    cout << **ptr << endl; // Original value of p as a address stored in p

    return 0;
}
                        
                    

Whats make this website differents from others?

Amazing Feature That Increase your Productivity

If you don't find any problem,in this website and if you have a very difficult assignment question that is not present on internet ,then you dont bother yourself,we are here to solve every problem of your life you just click on the Problem asking button and write your problem we slove the code of your problem and sent you on your email addres that you put in the sin up form.