P201. WAP to design a function which allocates dynamic memory for 1 student database and returns starting address of that.
#include<stdio.h>
#include<stdlib.h>
struct
st
{
int i;
char ch;
float f;
};
struct
st* data(void);
void
main()
{
struct st *q;
q=data();
printf("Enter integer value :
");
scanf("%d",&q->i);
printf("Enter character value :
");
scanf(" %c",&q->ch);
printf("Enter float value :
");
scanf("%f",&q->f);
printf("%d %c %f
\n",q->i,q->ch,q->f);
}
struct
st* data(void)
{
return malloc(sizeof(struct st));
}
Comments
Post a Comment