Guest User

Untitled

a guest
May 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.     short dtime, atime, fnumber, stops, time;
  8.     int let;
  9.     char days[7+1], from [3+1], to[3+1], fcode [2+1], fclass [10+1], acode[3+1];
  10.     char meal, dual;
  11.  
  12.     FILE *file = NULL;
  13.     file = fopen("flight.csv", "w");
  14.     if (file==NULL)
  15.     {
  16.         printf ("Error!");
  17.         return 1;
  18.     }
  19.  
  20.     while(1)
  21.     {
  22.         printf ("Unesi kod leta:\n");
  23.         scanf ("%d", &let);
  24.         if (let==0)
  25.             return 1;
  26.  
  27.         printf ("Unesi broj trajanje leta u danima:\n");
  28.         scanf ("%s", &days);
  29.  
  30.         printf ("Odakle:\n");
  31.         scanf ("%s", &from);
  32.  
  33.         printf ("Kamo:\n");
  34.         scanf ("%s", &to);
  35.  
  36.         printf ("Ocekivano vrijeme polijetanja:\n");
  37.         scanf ("%hd", &dtime);
  38.  
  39.         printf ("Ocekivano vrijeme dolaska:\n");
  40.         scanf ("%hd", &atime);
  41.  
  42.         printf ("Kod aviokompanije:\n");
  43.         scanf ("%s", &acode);
  44.  
  45.         printf ("Broj leta:\n");
  46.         scanf ("%hd", &fnumber);
  47.  
  48.         printf ("Klasa leta:\n");
  49.         scanf ("%s", &fclass);
  50.  
  51.         printf ("Kod zrakoplova:\n");
  52.         scanf ("%s", &fcode);
  53.  
  54.         printf ("Kod hrane:\n");
  55.         scanf (" %c", &meal);
  56.  
  57.         printf ("Broj zaustavljanja:\n");
  58.         scanf ("%hd", &stops);
  59.  
  60.         printf ("Dvostruki?(Y/N):\n");
  61.         do
  62.         {
  63.             scanf (" %c", &dual);
  64.         }
  65.         while (dual!='Y' && dual!='N');
  66.  
  67.         printf ("Ukupno vrijeme putovanja:\n");
  68.         scanf ("%hd", &time);
  69.  
  70.  
  71.         fprintf(file,"%d;%s;%s;%s;%hd;%hd;%s;%hd;%s;%s;%c;%hd;%c;%hd\n",
  72.         let,days,from,to,dtime,atime,acode,fnumber,fclass,fcode,meal,stops,dual,time);
  73.     }
  74.  
  75.     fclose(file);
  76.     return 0;
  77. }
Add Comment
Please, Sign In to add comment