int main()
{
	Library lib;
	int select = 0;
	
	lib.fBooks = "books.txt";
	lib.fCustomers = "customers.txt";

	// Load Books
	if(!loadBooks(lib.fBooks, lib.books, lib.maxBooks, lib.numBooks))
	{
		cout << "Failed to Load Books" << endl;
		return 0;
	}

	// Load Customers
	if(!loadCustomers(lib.fCustomers, lib.customers, lib.maxCust, lib.numCusts))
	{
		cout << "Failed to Load Customers" << endl;
		return 0;
	}

	// Menu
	while(select != 6)
	{
		printMenu();
		cin >> select;
		cout << endl;

		if(select == 1)
		{
			// List Books
			printBooks(lib.books, lib.numBooks);
		}
		else if(select == 2)
		{
			// Add Book To Deposit
			cout << "Book Title: ";
			cin.ignore();
			getline(cin, lib.books[lib.numBooks].title);

			cout << "Year Published: ";
			cin >> lib.books[lib.numBooks].yearPublished;
			
			cout << "Number of Pages: ";
			cin >> lib.books[lib.numBooks].pages;
			
			lib.books[lib.numBooks].checkedOut = false;
			lib.numBooks++;
			
			cout << "Book added." << endl << endl;
		}
		else if(select == 4)
Esempio n. 2
0
int main(void) {

	Book * books = NULL;
	char read[STRING_LENGTH];
	int added = 0;

	if(fgets(read, STRING_LENGTH, stdin) == NULL) { return -1; }

	while(strcmp(read, "DONE_FILL\n") != 0) {

		if (strlen(read) > 1) {
			books = addBook(parseString(read), read, books, &added);
		}

		if(fgets(read, STRING_LENGTH, stdin) == NULL) { return -1; }
	}

	printf("Books added: %d\n", added);

	if(fgets(read, STRING_LENGTH, stdin) == NULL) { return -1; }

	while(strcmp(read, "DONE_SEARCH\n") != 0) {

		if (strlen(read) > 1) {
			parseString(read);
			printf("Results found for %s: %d\n", read, searchBooks(read, books));
		}

		if(fgets(read, STRING_LENGTH, stdin) == NULL) { return -1; }
	}

	printBooks(books);
	freeBooks(books);

	return 0;
}