ifstream reader Not Reading .txt ?

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
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    const int RANGE = 12;
	string tab[ RANGE];
	int i = 0, j = 0;
   	ifstream reader ("records.txt");
	return 0;
	if ( ! reader)
{
	cout << "Error opening input file" << endl;
	return -1;
}

while ( ! reader.eof() )
{ 
	if ( ( i + 1 ) % 4 == 0 )
    getline( reader, tab[i++], '\n');
    else
	getline( reader, tab[i++], '\t');
}
    reader.close();
    i = 0;
while ( i < RANGE)

	cout << endl << "Record Number: " << ++j << endl;
	cout << "Forename:" << tab [i++] << endl;
	cout << "Surname:" << tab [i++] << endl;
	cout << "Deparment:" << tab[ i++] << endl;
	cout << "Telephone:" << tab [i++] << endl;
	}


I'm reading and learning from a book and it's been great, but I'm stuck on this. I've used ifstream before but all that happens with this code is it runs and does nothing. It's suppose to read the txt file and output them in the correct format. I've tried putting the .txt in the project folder, debug and everything just can't figure it out. Any ideas? Thanks :)
Topic archived. No new replies allowed.