#include"header.h"
void avion::citireZbor(void)
{
char temp[100];
int p[100];
ifstream f("data.txt");
if(!f)
{
cerr<<"Eroare la deschiderea fisierului";
//exit(EXIT_FAILUARE);
}
f>>nrZboruri;
char **destinatie=newchar*[nrZboruri];
char **plecare=newchar*[nrZboruri];
char **companie=newchar*[nrZboruri];
int **oraDecolare=newint*[nrZboruri];
int **dataDecolare=newint*[nrZboruri];//decolare
int **oraAterizare=newint*[nrZboruri];
int **dataAterizare=newint*[nrZboruri];
for (int i=0;i<nrZboruri;i++)
{
//citire destinatie
f.getline(temp,99);
destinatie[i]=newchar[strlen(temp)+1];
strcpy(destinatie[i],temp);
//citire plecare
f.getline(temp,99);
plecare[i]=newchar[strlen(temp)+1];
strcpy(plecare[i],temp);
//citire numele companiei
f.getline(temp,99);
companie[i]=newchar[strlen(temp)+1];
strcpy(companie[i],temp);
//ora decolare
f>>p[100];
oraDecolare[i]=newint[sizeof(p)+1];
oraDecolare[i]=p;
//ora aterizare
f>>p[100];
oraAterizare[i]=newint[sizeof(p)+1];
oraAterizare[i]=p;
//data decolare
f>>p[100];
dataDecolare[i]=newint[sizeof(p)+1];
dataDecolare[i]=p;
//data aterizare
f>>p[100];
dataAterizare[i]=newint[sizeof(p)+1];
dataAterizare[i]=p;
cout<<"destinatia este : "<<destinatie[i]<<endl;
}
f.close();
}
date.txt
1 2 3 4 5 6 7 8
3Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
Destinatie1 Plecare1 Companie1 10:22:3311 11:22:3311 12.9.201411 12.9.201411
Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
and the output is:
1 2 3
destinatia este : Destinatie Plecare Companie 10:22:33 11:22:33 12.9.2014 12.9.2014
destinatia este :
destinatia este :
what I want is to read the first word from file in -> destinatii(destinations)
the second word in -> plecari (departures)
and so on up to dataAterizari.
The project tries to manage an airport and finally in destinations i] should have only destinations in departures to have only departures and so on, but this does not happen.
THX :)