Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. //modulo item_song
  2. #include "item.h"
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "song.h"
  7. #define N 50
  8.  
  9. Item inputItem(){
  10.   char title[N], name[N];
  11.   unsigned int time;
  12.   printf("Inserisci il nome della band/cantante: ");
  13.   scanf("%[^\n]%*c", title);
  14.   printf("Inserisci il titolo della canzone: " );
  15.   scanf("%[^\n]%*c",name );
  16.   printf("Inserisci la durata della canzone in secondi: ");
  17.   scanf("%d%*c",&time );
  18.   printf("\n\n");
  19.   return (new_song(title,name,time));
  20. }
  21.  
  22. void outputItem(Item item){
  23.   Song p=item;
  24.   printf("Titolo: %s\nNome cantante/band: %s\nDuranta: %d\n\n",title_song(p),name_band(p),time_song(p));
  25. }
  26.  
  27. int cmpItem(Item item1, Item item2){
  28.   Song title1=item1;
  29.   Song title2=item2;
  30.   return(strcmp(title_song(title1),title_song(title2)));
  31. }
  32.  
  33. void delete_memory(Item item){
  34.   Song p=item;
  35.   free_song(p);
  36. }
  37.  
  38. Item cloneItem(Item item){
  39.   char title[N], name[N];
  40.   unsigned int time;
  41.   Song p=item;
  42.   strcpy(title,title_song(p));
  43.   strcpy(name,name_band(p));
  44.   time=time_song(p);
  45.   return new_song(title,name,time);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement