P193. WAP to allocate dynamic memory to 1 students database, scan it and print it.
#include<stdio.h>
#include<stdlib.h>
struct
st
{
int roll;
char name[10];
float marks;
};
void
main()
{
struct st *p;
p=malloc(sizeof(struct st));
printf("Enter roll number
:");
scanf(" %d",&p->roll);
printf("Enter name number
:");
scanf(" %s",p->name);
printf("Enter total marks
:");
scanf("%f",&p->marks);
printf("%d %s %f\n", p->roll,p->name,p->marks);
free(p);
}
Comments
Post a Comment