Advertisement
sujonshekh

structure

Jun 3rd, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct Books {
  5.    char  title[50];
  6.    char  author[50];
  7.    char  subject[100];
  8.    int   book_id;
  9. };
  10.  
  11. int main( ) {
  12.     int i;
  13.    struct Books Book[3];
  14.            /* Declare Book1 of type Book /* Declare Book2 of type Book */
  15.     for(i=0; i<3;i++)
  16.     {
  17.        scanf("%s",&Book[i].title);
  18.        scanf("%s",&Book[i].author);
  19.        scanf("%s",&Book[i].subject);
  20.        scanf("%d",&Book[i].book_id);
  21.     }
  22.    /* book 1 specification */
  23.    //scanf( "%s",&Book1.title);
  24.       /* book 2 specification */
  25.    /* print Book1 info */
  26.    for(i=0; i<3; i++)
  27.    {
  28.        printf( "Book %d title : %s\n",i, Book[i].title);
  29.        printf( "Book %d author : %s\n",i, Book[i].author);
  30.        printf( "Book %d subject : %s\n",i, Book[i].subject);
  31.        printf( "Book %d book_id : %d\n",i, Book[i].book_id);
  32.        printf("\n");
  33.    }
  34.  
  35.    return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement