Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- int main()
- {
- short dtime, atime, fnumber, stops, time;
- int let;
- char days[7+1], from [3+1], to[3+1], fcode [2+1], fclass [10+1], acode[3+1];
- char meal, dual;
- FILE *file = NULL;
- file = fopen("flight.csv", "w");
- if (file==NULL)
- {
- printf ("Error!");
- return 1;
- }
- while(1)
- {
- printf ("Unesi kod leta:\n");
- scanf ("%d", &let);
- if (let==0)
- return 1;
- printf ("Unesi broj trajanje leta u danima:\n");
- scanf ("%s", &days);
- printf ("Odakle:\n");
- scanf ("%s", &from);
- printf ("Kamo:\n");
- scanf ("%s", &to);
- printf ("Ocekivano vrijeme polijetanja:\n");
- scanf ("%hd", &dtime);
- printf ("Ocekivano vrijeme dolaska:\n");
- scanf ("%hd", &atime);
- printf ("Kod aviokompanije:\n");
- scanf ("%s", &acode);
- printf ("Broj leta:\n");
- scanf ("%hd", &fnumber);
- printf ("Klasa leta:\n");
- scanf ("%s", &fclass);
- printf ("Kod zrakoplova:\n");
- scanf ("%s", &fcode);
- printf ("Kod hrane:\n");
- scanf (" %c", &meal);
- printf ("Broj zaustavljanja:\n");
- scanf ("%hd", &stops);
- printf ("Dvostruki?(Y/N):\n");
- do
- {
- scanf (" %c", &dual);
- }
- while (dual!='Y' && dual!='N');
- printf ("Ukupno vrijeme putovanja:\n");
- scanf ("%hd", &time);
- fprintf(file,"%d;%s;%s;%s;%hd;%hd;%s;%hd;%s;%s;%c;%hd;%c;%hd\n",
- let,days,from,to,dtime,atime,acode,fnumber,fclass,fcode,meal,stops,dual,time);
- }
- fclose(file);
- return 0;
- }
Add Comment
Please, Sign In to add comment