P192. Wap to understand structure pointer.

 

#include<stdio.h>

#include<string.h>

struct st

{

        int roll;

        char name[10];

        float marks;

};

 

void main()

{

        struct st v={16,"Chinmay",85.78},*p;

        p=&v;

 

        printf("%d %s %f \n",v.roll,v.name,v.marks);

        printf("%d %s %f \n",p->roll,p->name,p->marks);

 

        p->roll = 17;

        strcpy(p->name,"Abhinav");

        p->marks = 95;

 

        printf("%d %s %f \n",p->roll,p->name,p->marks);

}

Comments