Loading arrays from a text file

I have a data storing console app, and it works like a charm but i have no way of saving the array data,(I have included fstream, to save the data to text),is there a way to use ifstream to load the data from another file, i have tried but it doesn't work.Here is the snippet that i tried...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
	ifstream infile;
	infile.open("array1.txt");

	for(int i = 0;i <3000;i++)
	{
		array1++;
		infile >> caseNumber[array1];
	}
	infile.close();


	ifstream infile2;
	infile2.open("array2.txt");

	for(int i = 0;i <3000;i++)
	{
		array2++;
		infile2 >> names[array1];
	}
	infile2.close();

try getline in a loop that starts like this:

while(infile)
Last edited on
what arguments do i have to use with getline?
thank you
Topic archived. No new replies allowed.