Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FLUSH while(getchar()!='\n')
- #define S 15
- typedef struct {
- char cognome[S], nome[S];
- unsigned short eta;
- }tipobaseList;
- void LeggiStringa(char s[],unsigned long dim){
- unsigned long i=0;
- for (i=0; (s[i]=getchar())!='\n' && i<dim-1;i++);
- s[i]='\0';
- if (i==dim-1) while (getchar()!='\n');
- }
- void LeggiElementoList(tipobaseList * x){
- printf("\nInserisci l'Elemento ");
- printf("\nInserisci il Cognome ");
- LeggiStringa(x->cognome, S);
- printf("\nInserisci il Nome ");
- LeggiStringa(x->nome, S);
- printf("\nInserisci l'eta' ");
- scanf("%d",&x->eta);
- FLUSH;
- }
- void CercaElementoList(tipobaseList * x){
- printf("\nRicerca per Cognome e Nome ");
- printf("\nInserisci il Cognome ");
- LeggiStringa(x->cognome, S);
- printf("\nInserisci il Nome ");
- LeggiStringa(x->nome, S);
- }
- void VisualizzaElementoList(tipobaseList x){
- printf("\n\nElemento ");
- printf("\nCognome = %s ", x.cognome);
- printf("\nNome = %s ", x.nome);
- printf("\nEta' = %d \n\n",x.eta);
- }
- void ModificaElementoList(tipobaseList * x){
- printf("\nModifica l'Eta' = % d ",x->eta);
- printf("\nInserisci la nuova Eta' ");
- scanf("%d",&x->eta);
- FLUSH;
- }
- int Confronta(tipobaseList a, tipobaseList b){
- if (!strcmp(a.cognome,b.cognome))
- return strcmp(a.nome,b.nome);
- else return strcmp(a.cognome,b.cognome);
- }
Advertisement
Add Comment
Please, Sign In to add comment