Don't like ads? PRO users don't see any ads ;-)
Guest

Implementazione QUEUE con puntatori

By: mittimus on Jul 17th, 2012  |  syntax: C  |  size: 0.68 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }