
Implementazione QUEUE con puntatori
By:
mittimus on
Jul 17th, 2012 | syntax:
C | size: 0.68 KB | hits: 14 | expires: Never
#define FLUSH while(getchar()!='\n')
#define S 15
typedef struct {
char cognome[S], nome[S];
unsigned short eta;
}tipobaseQueue;
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 LeggiElementoQueue(tipobaseQueue * x){
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 VisualizzaElementoQueue(tipobaseQueue x){
printf("\nCognome = %s ", x.cognome);
printf("\nNome = %s ", x.nome);
printf("\nEta' = %d \n\n",x.eta);
}