data txt file, display and void

How do I copy/find data, display records in uppercase, and find averages using void function? I'm not sure if I'm doing it right either. Main problem is finding uppercase in display, do I do toupper(c) ??

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

const int N=5;

struct RECORD
{
	string Name;
	int Age;
	float Gpa;
};
RECORD p[N];

void CopyRecords (string filename, RECORD p[N]);
void Display (RECORD x[]);
void AgeGpaAverage(int N[]); 

int main()
{
	int AgeAve;
	float GpaAve;
	
	//Read data from this file into array p
	CopyRecords("data2.txt",p);

	//Display all records
	Display(p);

	//Compute age and GPA average
	AgeGpaAverage(p, AgeAve, GpaAve); 

	//Terminate Program
	system ("pause");
	return 0;
}
void CopyRecords (string filename, RECORD p[N])
{
	ifstream f;
	f.open(filename, ios::in);
	
	for(int i = 0; i <=5; ++i)
	{
		f >> p[i].Name;
	}
}
void Display (RECORD x[])
{
	for (int i = 0; i < N; ++i)
		cout << x[i].Name << " " << x[i].Age << " " << x[i].Gpa << endl;
}



I/O should look like:
1
2
3
4
5
Martin-Smith 22 2.2 
Austin-Clinton 18 3.1
Johnson 19 2.9
Maggie-Jones 23 2.3
Tyler-Brown 16 3.4

Last edited on
Topic archived. No new replies allowed.