Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define NFIL 6 //los valores numéricos de NFIL y NCOL pueden cambiar
  4. #define NCOL 4
  5. #define LIBRE 0
  6. #define OCUPADO 1
  7. #define MAX 13
  8.  
  9. struct Tfecha {
  10. int dia, mes, anio;
  11. };
  12. // Datos de un vuelo:
  13. struct TDatosVuelo {
  14. char compania [10];
  15. char origen [10];
  16. char numVuelo [10];
  17. char destino [10];
  18. struct Tfecha fecha;
  19. int hora [2];
  20. };
  21. // Datos de la ocupación de un asiento
  22. struct TAsientos {
  23. int ocupado; /* 1=ocupado , 0=libre */
  24. char nombre[20]; /* nombre del pasajero */
  25. char nacionalidad[10]; /* nacionalidad del pasajero */
  26. int facturado; /* 1=si , 0=no */
  27. };
  28. // Datos del avión:
  29. struct TAvion
  30. {
  31. struct TDatosVuelo DVuelo;
  32. struct TAsientos Asientos [NFIL][NCOL];
  33. };
  34. void lectura(struct TAvion *a);
  35. void pasajeros(struct TAvion *a);
  36. int main()
  37. {
  38. struct TAvion avion1;
  39. //avion1.Asientos[NFIL][NCOL].facturado={0};
  40. printf("%dx%d",avion1.Asientos[0][0].facturado,avion1.Asientos[0][1].facturado);
  41. //lectura(&avion1);
  42. return 0;
  43. }
  44. void lectura(struct TAvion *a)
  45. {
  46. int pas=0,i,j;
  47. char string[MAX];
  48. FILE *fich;
  49. fich=fopen("datVuelo.txt","r");
  50. if(fich==NULL)
  51. printf("error fichero.\n");
  52. else
  53. {
  54. while(!feof(fich))
  55. {
  56. fscanf(fich,"%s",a->DVuelo.compania);
  57. fscanf(fich,"%s",a->DVuelo.origen);
  58. fscanf(fich,"%s",a->DVuelo.numVuelo);
  59. fscanf(fich,"%s",a->DVuelo.destino);
  60. fscanf(fich,"%d %d %d",a->DVuelo.fecha.dia,a->DVuelo.fecha.mes,a->DVuelo.fecha.anio);
  61. fscanf(fich,"%d %d",a->DVuelo.hora[0],a->DVuelo.hora[1]);
  62. for(pas=0;pas<5;pas++)
  63. {
  64. fscanf(fich,"%d %d",i,j);
  65. }
  66. }
  67. fclose(fich);
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement