Program for Pointer to Structure


    #include <iostream.h>
    #include <conio.h>
    void main ()
    {
        struct samplr
        {
            int x ;
            int y ;
        } a, *b ;
        clrscr ( ) ;
        a.x = 10 ;
        a.y = 20 ;
        b = &a;
        cout<<"x  :  " <<(*b).x<<endl;
               cout<<"y  :  "<<(*b).y<<endl ;
        cout<<"x  :  " <<b->x<<endl;
               cout<<"y  :  "<<b->y<<endl ;
        getch ( ) ;
    }

No comments:

Post a Comment