Problem reading from file

Hay,
I have a problem with the below code:

heder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 #ifndef HEDER_H_
#define HEDER_H_

#include<iostream>
#include<string.h>
#include<stdlib.h>
#include <cstring>
#include<fstream>

using namespace std;

class avion{
private:
	int nrZboruri;
	char **destinatie;
	char **plecare;
	char **companie;
	int **oraDecolare;
	int **dataDecolare;//decolare
	int **oraAterizare;
	int **dataAterizare;//aterizare

public:
	void citireZbor();
	void afisareZbor();
};

#endif /* HEDER_H_ */


functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#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=new char*[nrZboruri];
	char **plecare=new char*[nrZboruri];
	char **companie=new char*[nrZboruri];
	int **oraDecolare=new int*[nrZboruri];
	int **dataDecolare=new int*[nrZboruri];//decolare
	int **oraAterizare=new int*[nrZboruri];
	int **dataAterizare=new int*[nrZboruri];

	for (int i=0;i<nrZboruri;i++)
	{

		//citire destinatie
		f.getline(temp,99);
		destinatie[i]=new char[strlen(temp)+1];
		strcpy(destinatie[i],temp);


		//citire plecare
		f.getline(temp,99);
		plecare[i]=new char[strlen(temp)+1];
		strcpy(plecare[i],temp);

		//citire numele companiei
		f.getline(temp,99);
		companie[i]=new char[strlen(temp)+1];
		strcpy(companie[i],temp);

		//ora decolare
		f>>p[100];
		oraDecolare[i]=new int[sizeof(p)+1];
		oraDecolare[i]=p;

		//ora aterizare
		f>>p[100];
		oraAterizare[i]=new int[sizeof(p)+1];
		oraAterizare[i]=p;

		//data decolare
		f>>p[100];
		dataDecolare[i]=new int[sizeof(p)+1];
		dataDecolare[i]=p;

		//data aterizare
		f>>p[100];
		dataAterizare[i]=new int[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 :)
Topic archived. No new replies allowed.