programming-examples/c/Structures_and_unions/C program to read information of a book and display the information (Pointer to Structure as argument).c

25 lines
543 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*Pointer to Structure as argument*/
/*Write a program to read information of a book and display the information.*/
#include<stdio.h>
struct book
{
int bno;
char name[40];
};
void display(struct book*);
void main()
{
struct book b;
printf("\nEnter book no: ");
scanf("%d",&b.bno);
printf("Enter book name: ");
scanf("%s",b.name);
display(&b);
}
void display(struct book *b)
{
printf("\nDetails are: ");
printf("Book number= %d \n",b->bno);
printf("Book name= %s",b->name);
}