#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
int sn;
char *name;
}student;
student *std;
int n=0;
void inputd(student *std)
{
if(n<3)
{
printf("Input School Number :");
scanf("%d",&(std+n)->sn);
(std+n)->name=(char*)malloc(sizeof(char));
printf("Input Name:");
scanf("%s",(std+n)->name);
n++;
}
else
{
printf("memory full\n");
}
}
void outd(student *std)
{
int a;
for(a=0;a<n;a++)
{
printf("%d \t, %s\n",(std+a)->sn,(std+a)->name);
}
}
void main()
{
int a;
std=(student *)malloc(sizeof(student)*3);
while(1)
{
printf("1. Input Data\n");
printf("2. Out Data \n");
printf("3. Exit\n");
scanf("%d",&a);
switch(a)
{
case 1:
{
inputd(std);
break;
}
case 2:
{
outd(std);
break;
}
case 3:
{
free(std);
exit(0);
}
}
}
}