P196. WAP to understand how to handle a member if it’s a pointer.
#include<stdio.h>
#include<stdlib.h>
struct
st
{
int roll;
char *name;
float marks;
};
void
main()
{
struct st v;
v.name=malloc(10);
printf("Enter roll
number\n");
scanf("%d",&v.roll);
printf("Enter name
number\n");
scanf("%s",v.name);
printf("Enter total
marks\n");
scanf("%f",&v.marks);
printf("%d %s %f\n",
v.roll,v.name,v.marks);
}
Comments
Post a Comment