struct program help

int short i have a lot of errors involving my variables not being declared right also i am not sure if my function void fixDouble is set up correctly
i have attached the output and the code if anyone could help it would be awesome i know i am just missing something stupid.

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;
 int numrecs;
struct RecPerson
{
	string lName;
	string fName;
	int age;
	
};
void printRecords (RecPerson rec[], int size);
void displayOldest(RecPerson rec[],int size);
void displayYoungest(RecPerson rec[],int size);
void fixDouble(RecPerson rec[],int size);
void main(void)
{	
	cout<<"Plese Enter Max Number of Records"<<endl;
	cin>>numrecs;
	RecPerson people[10];
	for(int i =0;i<numrecs;i++)
	{
		cout<<"Enter First Name: "<<endl;
		cin>>people[i].fName;
		cout<<"Enter Last Name: "<<endl;
		cin>>people[i].lName;
		cout<<"Enter Age of Person: "<<endl;
		cin>>people[i].age;
		
	
	}
	fixDouble(&rec[i].fName,&rec[i].lName);
	displayOldest(people,numrecs);
	displayYoungest(people,numrecs);
	printRecords(people,numrecs);

	

}

void printRecords(RecPerson rec[], int size)
{
for (int i = 0; i<numrecs; i++)
	{
		cout<<rec[i].fName<<' '<<rec[i].lName<<setw(10)<<rec[i].age<<endl;

	}
}
void displayOldest(RecPerson rec[],int size)
{
	int oldest = 0;
	int age = 0 ;
	int temp = 0;
	for (int i=0; i<size; i++)
	{
		if (rec[i].age>age)
	{
		 age=rec[i].age;
		 oldest = i;
		
	}
		
	
	}
	cout<<"The Oldest age is: "<<rec[oldest].age<<endl;
}

void displayYoungest(RecPerson rec[],int size)
{
	int youngest = 0;
	int age = 0 ;
	int temp = 0;
	for (int i=0; i<size; i++)
	{
		if (rec[i].age<age)
	{
		 age=rec[i].age;
		 youngest = i;
		
	}
		
	
	}
	cout<<"The youngest age is: "<<rec[youngest].age<<endl;
}
void fixDouble(string a=rec[i].fName,string b=rec[i].lName)
{	int newfName,newlName;
	
	for(i=0,i<numrecs,i++;)
	{
	rec[i].fName = newfName;
	rec[i].lName = newlName;

	if (rec[i].fname=a&&rec[i].lName=b)
	{
	cout<<"This User has already been entered"<<endl;
	}
	}
}


1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(34): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(34): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(34): error C2228: left of '.fName' must have class/struct/union
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(34): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(34): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(34): error C2228: left of '.lName' must have class/struct/union
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(88): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(88): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(88): error C2228: left of '.fName' must have class/struct/union
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(88): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(88): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(88): error C2228: left of '.lName' must have class/struct/union
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(91): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(91): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(91): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(91): error C2143: syntax error : missing ';' before ')'
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(93): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(93): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(93): error C2228: left of '.fName' must have class/struct/union
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(94): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(94): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(94): error C2228: left of '.lName' must have class/struct/union
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(96): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(96): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(96): error C2228: left of '.fname' must have class/struct/union
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(96): error C2065: 'rec' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(96): error C2065: 'i' : undeclared identifier
1>c:\users\andrew\desktop\school\cs1\projects\lab11\lab11\andrewwellslab_11_1.cpp(96): error C2228: left of '.lName' must have class/struct/union
1>
Variables have scope
Topic archived. No new replies allowed.