Advertisement
Guest User

Untitled

a guest
May 30th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. int main(void)
  2. {
  3. typedef struct flights
  4.         {   int flight_id;
  5.             char flight_from[20];
  6.             char flight_to[20];
  7.             char flight_start_date[10];
  8.             char flight_start_time[6];
  9.             char flight_finish_date[10];
  10.             char flight_finish_time[6];
  11.             int flight_max_seats;
  12.         } flights;
  13.  
  14.  
  15.     struct flights jeden;{
  16.  
  17.         scanf("%d",&(jeden.flight_id));}
  18.     printf("Miasto odlotu:\n");
  19.     fflush(stdout);
  20.     scanf("%s",&jeden.flight_from);
  21.  
  22.     printf("Podaj miasto docelowe:\n");
  23.     fflush(stdout);
  24.     scanf("%s",&jeden.flight_to);
  25.  
  26.     printf("Podaj date wylotu:\n ");
  27.     fflush(stdout);
  28.     scanf("%s",&jeden.flight_start_date);
  29.  
  30.     printf("Podaj godzine wylotu:\n ");
  31.     fflush(stdout);
  32.     scanf("%s",jeden.flight_start_time);
  33.  
  34.     printf("Podaj date przylotu:\n ");
  35.     fflush(stdout);
  36.     scanf("%s",jeden.flight_finish_date);
  37.  
  38.     printf("Podaj godzine przylotu:\n ");
  39.     fflush(stdout);
  40.     scanf("%s",jeden.flight_finish_time);
  41.  
  42.     printf("Podaj liczbê miejsc:\n ");
  43.     fflush(stdout);
  44.     scanf("%d",&jeden.flight_max_seats);
  45.     //jeden.flight_id = 23;
  46.     //strcpy ( jeden.flight_from, "abc");
  47.  
  48.  
  49.     FILE *fp;
  50.     if((fp = fopen("flights_db.txt", "w+")) == NULL)
  51.     {
  52.         printf("Nie mozna otworzyc pliku do zapisu\n");
  53.         exit(1);
  54.     }
  55.  
  56.  
  57.  
  58.  
  59.     fprintf (fp, "%d;;%s;;%s\n",jeden.flight_id,jeden.flight_from, jeden.flight_to);
  60.  
  61.     fclose(fp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement