Md Nayeem

Md Nayeem

  • NA
  • 75
  • 22.8k

How can i implement a simple user define function in this

Jan 19 2018 12:10 AM
 How can i implement a simple user define function in this program?
 
  1. #include <stdio.h>  
  2. #include <string.h>  
  3.   
  4. struct Books {  
  5.    char  Name[50];  
  6.    char  author[50];  
  7.    char  subject[100];  
  8.    int   book_id;  
  9. };  
  10.   
  11. int main( ) {  
  12.   
  13.    struct Books Book1;        /* Declare Book1 of type Book */  
  14.    struct Books Book2;        /* Declare Book2 of type Book */  
  15.   
  16.    /* book 1 specification */  
  17.    strcpy( Book1.Name, "C Programming Learning ");  
  18.    strcpy( Book1.author, "Nuha Ali");  
  19.    strcpy( Book1.subject, "C Program");  
  20.    Book1.book_id = 6495407;  
  21.   
  22.    /* book 2 specification */  
  23.    strcpy( Book2.Name, "Telecom  Learning");  
  24.    strcpy( Book2.author, "Zara Ali");  
  25.    strcpy( Book2.subject, "Telecom");  
  26.    Book2.book_id = 6495700;  
  27.   
  28.    /* print Book1 info */  
  29.    printf( "Book 1 Name : %s\n", Book1.Name);  
  30.    printf( "Book 1 author : %s\n", Book1.author);  
  31.    printf( "Book 1 subject : %s\n", Book1.subject);  
  32.    printf( "Book 1 book_id : %d\n", Book1.book_id);  
  33.   
  34.    /* print Book2 info */  
  35.    printf( "Book 2 Name : %s\n", Book2.Name);  
  36.    printf( "Book 2 author : %s\n", Book2.author);  
  37.    printf( "Book 2 subject : %s\n", Book2.subject);  
  38.    printf( "Book 2 book_id : %d\n", Book2.book_id);  
  39.   
  40.    return 0;  
  41. }  

Answers (1)