Page 119 - 6437
P. 119

strcpy( Book2.subject, "Telecom Billing Tutorial");

                                Book2.book_id = 6495700;


                                /* print Book1 info */
                                printf( "Book 1 title : %s\n", Book1.title);

                                printf( "Book 1 author : %s\n", Book1.author);
                                printf( "Book 1 subject : %s\n", Book1.subject);

                                printf( "Book 1 book_id : %d\n", Book1.book_id);


                                /* print Book2 info */
                                printf( "Book 2 title : %s\n", Book2.title);

                                printf( "Book 2 author : %s\n", Book2.author);
                                printf( "Book 2 subject : %s\n", Book2.subject);

                                printf( "Book 2 book_id : %d\n", Book2.book_id);


                                return 0;
                            }

                          When the above code is compiled and executed, it produces the following result:

                                                  title : C Programming
                                   ook
                                                  author : Nuha Ali
                                   ook
                                                  subject : C Programming Tutorial
                                   ook
                                                  book_id : 6495407
                                   ook
                                                  title : Telecom Billing
                                   ook
                                                  author : Zara Ali
                                   ook
                                                  subject : Telecom Billing Tutorial
                                   ook
                                                  book_id : 6495700
                                   ook

                          Structures as Function Arguments
                          You can pass a structure as a function argument in the same way as you pass any other
                   variable or pointer.


                 #include <stdio.h>
                                                                                                     122
                 #include <string.h>
   114   115   116   117   118   119   120   121   122   123   124