P199. Different ways to access data of struct data type.
#include<stdio.h>
struct
st
{
int rollno;
char name[20];
float t_marks;
};
void
print(int ,char*,float);
void
print1(struct st);
void
print2(struct st*);
void
main()
{
struct st v =
{10,"abcd",45.5};
print(v.rollno,v.name,v.t_marks);
print1(v);
print2(&v);
printf(" Main : %d %s %f
\n",v.rollno,v.name,v.t_marks);
}
void
print(int r,char *p,float m)
{
printf(" Print : %d %s %f
\n",r,p,m);
}
void
print1(struct st v)
{
printf(" Print1 : %d %s %f
\n",v.rollno,v.name,v.t_marks);
}
void
print2(struct st *p)
{
printf(" Print2 : %d %s %f
\n",p->rollno,p->name,p->t_marks);
}
Comments
Post a Comment