//testing some structs
#include <stdio.h>
struct books {
char title[50];
char author[50];
char subject[100];
int book_id;
} book;
//Function Declairations
int print_book(struct books book);
int main() {
struct books book1;
struct books book2;
strcpy(book1.title, "Spot goes to the beach");
strcpy(book1.author, "Mr Biggles");
strcpy(book1.subject, "A story of a stupid little dog that goes to the beach and chases birds.");
book1.book_id = 684687654;
strcpy(book2.title, "The Cat in the Hat");
strcpy(book2.author, "Dr Seuse");
strcpy(book2.subject, "A mischeviouse cat come to visit and causes such a mess");
book2.book_id = 5754454;
printf("Available books for hire from the library\n");
print_book(book1);
print_book(book2);
}
int print_book(struct books book) {
//prints the details of a books struct parsed as a parameter
printf("\nBook Title: %s", book.title);
printf("\nBook Author: %s", book.author);
printf("\nBook Subject: %s", book.subject);
printf("\nBook ID: %d", book.book_id);
printf("\n");
}
Hey guys for some reason \n
has randomly stopped working. I decided to add another \n
at the bottom just to separate the output from the "press any key to continue..." from the console window at the end but it's not working now.
I've even tried going to line 28 and just inserting more \n
's eg...
printf("Available b\n\n\n\n\n\n\nooks for hire from the library\n");
with no difference in the output.