Example #1
0
int main(void)
{
	book library[MAXBKS];
	int count = 0;

	printf("Please enter the book title.\n");
	printf("Press [enter] at the start of a line to stop.\n");
	while (count < MAXBKS && gets(library[count].title) != NULL
	       && library[count].title[0] != '\0') {
		printf("Now enter the author.\n");
		gets(library[count].author);
		printf("Now enter the value.\n");
		scanf("%f", &library[count++].value);
		while (getchar() != '\n')
			continue;          /* clear input line         */
		if (count < MAXBKS)
			printf("Enter the next title.\n");
	}

	if (count > 0) {
		puts("Here is the list of your books:");
		print_delim();
		print_library(library, count);

		puts("\nSorted alphabetically:");
		print_delim();
		sort(library, count, alphabetically);
		print_library(library, count);

		puts("\nSorted by value:");
		print_delim();
		sort(library, count, by_value);
		print_library(library, count);
	} else
		printf("No books? Too bad.\n");

	return 0;
}
Example #2
0
File: main.c Project: mks65/tunez
int main() {
  srand((unsigned) time(NULL));
  
  printf("LIBRARY\n");
  printf("=======\n");
  add_song(table, "hello", "adele");
  add_song(table, "arabella", "arctic monkeys");
  add_song(table, "formation", "beyonce");
  add_song(table, "sorry", "beyonce");
  add_song(table, "cardiac arrest", "bad suns");
  add_song(table, "summer", "calvin harris");
  add_song(table, "closer", "the chainsmokers");
  print_library(table);
  printf("\n");
  
  printf("searching for \'closer - the chainsmokers\'\n");
  printf("===========================================\n");
  song_node *findSong = find_song(table, "closer", "the chainsmokers");
  if (findSong) printf("found %s - %s\n", findSong->name, findSong->artist);
  printf("\n");
  
  printf("searching for \'kids - mgmt\'\n");
  printf("=============================\n");
  song_node *findSong2 = find_song(table, "kids", "mgmt");
  if (findSong2) printf("found %s - %s\n", findSong2->name, findSong2->artist);
  printf("\n");
    
  printf("searching for adele\n");
  printf("===================\n");
  song_node *findArtist = find_artist(table, "adele");
  if (findArtist) print_list(findArtist);
  printf("\n");
  
  printf("searching for akmu\n");
  printf("===================\n");
  song_node *findArtist2 = find_artist(table, "akmu");
  if (findSong2) print_list(findArtist2);
  printf("\n");
  
  printf("print \'b\'\n");
  printf("===========\n");
  print_letter(table, "b");
  printf("\n");
  
  printf("print beyonce\n");
  printf("=============\n");
  print_artist(table, "beyonce");
  printf("\n");
  
  printf("print entire library\n");
  printf("====================\n");
  print_library(table);
  printf("\n");
  
  printf("shuffle and list three songs\n");
  printf("============================\n");
  shuffle(table, 3);
  printf("\n");
  
  printf("deleting a song\n");
  printf("===============\n");
  printf("deleting \'summer - calvin harris\'\n");
  delete_song(table, "summer", "calvin harris");
  print_library(table);
  printf("\n");
  
  printf("deleting everything (FAULTY)\n");
  printf("============================\n");
  delete_all(table);
  print_library(table);
}
Example #3
0
void delete_song(char song[], char artist[]){
	printf("\n deleting %s - %s", artist, song);
	table[artist[0]-97] = remove_song(table[artist[0]-97], song, artist);
	print_library();
}