Airport.c

Classified in Other subjects

Written at on English with a size of 2.25 KB.

 
#include <stdio.H>
#include <stdlib.H>
#include "airport.H"

int readFile(flightInfo* flights, int size, FILE* fileIn){
    printf("reading file...\n");
    int i=0;
    char buffer[1024];
    while ( fgets(buffer, 1023, fileIn)!= NULL ){
        //printf("while\n");
        
        sscanf(buffer, "%d,%d,%[^,],%s", &flights[i].Passengers ,&flights[i].Id, flights[i].Source, flights[i].Destination );
       
        
        if( i<2){
            
            printf("%d,%d,%s,%s\n", flights[i].Passengers, flights[i].Id, flights[i].Source, flights[i].Destination);
            
        }
        
        I++;
    }
    return i;
}
 void writeFile(flightInfo* flights, int totalFlights, FILE* fileOut){
     int i = 0;
     for (i = 0 ; i< totalFlights; i++){
         fprintf(fileOut, "%d,%s,%s\n",flights[i].Passengers, flights[i].Source,flights[i].Destination);
         if(i<2){
             printf("%d,%s,%s\n",flights[i].Passengers, flights[i].Source,flights[i].Destination);
         }
     }
 }
100%

Entradas relacionadas: