-->
Showing posts with label program to understand pointer's pointer. Show all posts
Showing posts with label program to understand pointer's pointer. Show all posts

program to understand pointer's pointer

using codeblocks
----------------------------------------------------------------------------------
//understanding pointer's pointer
#include <stdio.h>

int main()
{
    int **p,*p1;                  //two pointer declaration
    int x=5;
    p1=&x;                        //stores address of x to pointer p1
    printf("first address p1=%d\n",p);//prints that first address
    p=&p1;                         //stores address of pointer by pointer
    printf("address p=%d\n",p);//prints that pointer's address
    return 0;
}
--------------------------------------------------------------------------------

using turboc++
----------------------------------------------------------------------------

//understanding pointer's pointer
#include <stdio.h>
#include <conio.h>

int main()
{
    int **p,*p1;                  //two pointer declaration
    int x=5;
    p1=&x;                        //stores address of x to pointer p1
    printf("first address p1=%d\n",p);//prints that first address
    p=&p1;                         //stores address of pointer by pointer
    printf("address p=%d\n",p);//prints that pointer's address
   getch();
    return 0;
}