a simple programme needs to be solved ! help please

Hello
im trying to create programme that shows the user number of readers by age group
the survey data is as the following(as in txt file):
under 20
20 to 29
30 to 39
40 to 49
older than 50 when the user enter 1
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
Age Gender MaritalStatus Income
18      M         S        0
19      F         M        10800
20      F         S        14400
22      F         S        28000
23      F         M        15000
25      F         S        28000
26      F         S        32000
27      M         S        38000
28      F         M        0
28      M         M        60000
30      M         S        56000
31      F         S        50000
32      M         S        28000
33      F         M        18000
35      F         S        10000
35      M         S        36000
36      M         M        48000
37      F         M        24000
38      M         S        40000
42      M         M        62000
45      M         M        48000
46      M         M        36000
47      M         M        31000
48      F         M        64000
48      M         M        58000
48      M         M        72000
49      M         S        52000
50      M         M        65000
52      M         M        80000
55      M         M        68000


but so far my programme is:
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
#include <cstdlib>
#include <iostream>
#include <fstream>

using namespace std;
void printReaders() {
     ifstream infile("SurveyData.txt");
char line[256];

if (infile.is_open())
{
	while(!infile.eof())
	{
		infile.getline(line, 256);
		cout << line << endl;
	}
}
else
{
	cerr << "Error opening file";
}


infile.close();
               }

int main()
{
    double a;
    cout<<"Please enter number 1 for viewing readers by age group"<<endl;
    cin>>a;
    printReaders();
    
    
    
    system("PAUSE");
    return 0;
}

Your help will be much appreciated
Last edited on
Topic archived. No new replies allowed.