Structure Pointer
Structure is a method of packing data of different types.
A structure is a convenient method of handling a group of related data items of different data types.
/*
http://www.ProbCOMP.com
Structure is a method of packing data of different types.
A structure is a convenient method of handling a group of related data items of different data types.
A structure pointer is same as normal pointer, it stores the address of a strucutre of the given type.
*/
#include<stdio.h>
struct student
{
char name[20];
int age;
float percentage;
};
typedef struct student STUDENT;
void read(STUDENT *stu)
{
printf("enter name: ");
gets(stu->name);
printf("\nenter age: ");
scanf("%d",&stu->age);
printf("\nenter percentage: ");
scanf("%f",&stu->percentage);
}
void show(STUDENT *stu)
{
printf("\nname : %s",stu->name);
printf("\nage : %d",stu->age);
printf("\nperceantge : %f",stu->percentage);
}
void main()
{
STUDENT stu1,stu2;
read(&stu1);
read(&stu2);
show(&stu1);
show(&stu2);
}
Download Program


