Exemplo n.º 1
0
int main() {
	int cho;
	char check,c,esc;
	
	system("clear");
	strcpy(filename,"pranav");
	while(1)
	{    	
		system("clear");
		printf(BOLDYELLOW"\n\n\n\n\n\t\t\t\t\t----------------------*******---------------------"RESET);
		printf(BOLDCYAN"\n\n\n\t\t\t\tHello !! Welcome to PRANAV's Library --- choose from the following menu"RESET);
		printf(YELLOW"\n\n\n\t\t\t\t\t1.Add Book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t2.Display Book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t3.Delete Book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t4.Search a Book "RESET);
		printf(YELLOW"\n\n\t\t\t\t\t5.Edit available book Information"RESET);
		printf(YELLOW"\n\n\t\t\t\t\t6.Exit from this menu"RESET);
		printf(BOLDYELLOW"\n\n\n\n\n\t\t\t\t\t----------------------*******---------------------"RESET);
		printf(BOLDCYAN"\n\n\t\t\t\t\t\t Your Choice:"RESET);
		scanf("%d",&cho);
		switch(cho)
		{
			case 1:
					Password();
					addbook();
					break;
			case 2:
					display_book(lib);
					sleep(2);
					break;
			case 3:
					Password();			
					delete_book(lib);
					sleep(2);
					break;
			case 4:
					search(lib);
					sleep(2);
					break;
			case 5:
					Password();
					edit_info(lib);
					break;
			case 6:
					exitp();
			default:
					printf(BOLDRED"\n\t\t\t\tChoose from following choices only \n"RESET);
					printf(RED"\t\t\tEnter 1 2 3 4 5 6 7"RESET);
		}
	}
}
/* Диалог удаления */
void delete_dialog(BookDB* db) {
	int id;
	output("Введите номер книги\n");
	input("%i", &id);
	Book *book = get_by_id(db, id);
	if (!book) {
		output("Книга с id: %d не найдена!\n", id);
		return; 
	}
	output("Вы точно хотите удалить книгу %s? (yes/no)\n", book->title);
	char answer[MAX_STRING_LENGTH];
	input("%s", answer);
	if (!strcmp(answer, "y") || !strcmp(answer, "yes")) {
		delete_book(db, book);
		db->saved = 0;
		output("Книга удалена!\n");
	}
}