creaLibro(aut, tit, ed, an) = lb
Postcondizione: lb = (aut, tit, ed, an)
autore(lb) = aut
Postcondizione: lb.autore = aut
titolo(lb) = tit
Postcondizione: lb.titolo = tit
editore(lb) = ed
Postcondizione: lb.editore = ed
anno(lb) = an
Postcondizione: lb.anno = an
typedef struct lib
{
char autore[26];
char titolo[53];
char editore[26];
int anno;
} libro;
libro creaLibro(char *aut, char *tit, char *ed, int anno);
char *autore(libro l);
char *titolo(libro l);
char editore(libro l);
int anno(libro l);
#include "libro.h"
libro creaLibro(char *aut, char *tit, char *ed, int anno)
{
libro l;
strcpy(l.autore, aut);
strcpy(l.titolo, tit);
strcpy(l.editore, ed);
l.anno = an;
return l;
}
char *autore(libro L)
{
char *aut;
aut = calloc(26, sizeof(char));
strcpy(aut, L.autore);
return aut;
}
char *titolo(libro L)
{
char *tit;
tit = calloc(53, sizeof(char));
strcpy(tit, L.titolo);
return tit;
}
char *editore(libro L)
{
char *ed;
ed = calloc(26, sizeof(char));
strcpy(ed, L.editore);
return ed;
}
int anno(libro L)
{
return L.anno;
}