mittimus

Implementazione QUEUE con puntatori

Jul 17th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #define FLUSH while(getchar()!='\n')
  2. #define S 15
  3. typedef struct {
  4. char cognome[S], nome[S];
  5. unsigned short eta;
  6. }tipobaseQueue;
  7. void LeggiStringa(char s[],unsigned long dim){
  8. unsigned long i=0;
  9. for (i=0; (s[i]=getchar())!='\n' && i<dim-1;i++);
  10. s[i]='\0';
  11. if (i==dim-1) while (getchar()!='\n');
  12. }
  13. void LeggiElementoQueue(tipobaseQueue * x){
  14. printf("\nInserisci il Cognome ");
  15. LeggiStringa(x->cognome, S);
  16. printf("\nInserisci il Nome ");
  17. LeggiStringa(x->nome, S);
  18. printf("\nInserisci l'eta' ");
  19. scanf("%d",&x->eta);
  20. FLUSH;
  21. }
  22. void VisualizzaElementoQueue(tipobaseQueue x){
  23. printf("\nCognome = %s ", x.cognome);
  24. printf("\nNome = %s ", x.nome);
  25. printf("\nEta' = %d \n\n",x.eta);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment