Pointers

sAksham-Ar published on
1 min, 96 words

Categories: C++

Pointers in C++ basically store memory locations where a variable is stored.To access its value you can use * behind its name and also to declare them.The name of an array is a constant pointer.An & behind a variable gives its address.The address is displayed in hexadecimal.

#include<iostream>
using namespace std;
int main()
{
    int a=9,b[]={1,2,3,4,5},*c;
    c=&a;
    cout<<"The memory address of a is:\n"<<c<<"\nAnd its value is:\n"<<*c;
    cout<<"\nFirst element of b:\n"<<*b<<" \nThird element of b:\n"<<*(b+3);
    return 0;
}

OUTPUT:

output