My loop doesn't increment

With this little code, I have 2 issues, both surrounding the loop of mine.
I have a list of students' ages, and I want to input a value and loop all students lineary until it matches a student.

The other issue I found was that even if the value inside the loop is equal to what I'm checking, it wouldn't trigger my if statement. I tested this by searching for Age 1 while the first student in the list was also Age 1.
Here's my full code with 2 debug lines and a print screen of my run of it.
Apologies for not commenting my code yet.


Here's a print screen of the run I did:
http://i.gyazo.com/c806e9f99e0e8815f93a7010eb24418c.png
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
#include <string>

using namespace std;

class Student
{
public:

	string name;
	int age;

	void print()
	{
		cout << "Student: " << name << endl;
		cout << "Age: " << age << endl;
	}

	void store(string _name, int _age)
	{
		name = _name;
		age = _age;
	}


};

int LinearSearch(Student* studentArray, int age)
{
	for (int i = 1; i <= 14; i++)
	{
		cout << "DEBUG AGE: " << age << endl; 
		cout << "DEBUG: Searched student: " << i << " His age was: " << studentArray[i].age << endl;
		if (studentArray[i].age = age)
		{
			return i;
		}
	}
	return -1;
}

int main()
{

	Student student[10];
	string name;
	string teacher;
	int age;

	int students;

	cout << "Welcome, what's your name?: ";
	cin >> teacher;
	cout << "Welcome to your new job, " << teacher << ".\n\n";

	cin.get();
	cout << "As a new teacher, you will have to set up your class in this program.";
	cin.get();
	cout << "Note that you're only allowed to teach 14 students as max.";
	cin.get();
	cout << "How many students are you going to be teaching this semester?: ";
	cin >> students;

	int i;
	for (i = 1; i <= students; i++)
	{
		cout << "Enter student name: ";
		cin >> name;
		cout << "Enter student age: ";
		cin >> age;

		student[i].store(name, age);
	}
	
	cout << "You have " << students << " students.\n";
	cout << "Let's make sure they got put in correctly.\n";
	cout << "Print student ID: ";

	int input;

	while (true)
	{
		cin >> input;
		if (input <= students)
		{
			student[input].print();
			break;
		}
		else
		{
			cout << "Error, student " << input << " does not exist. Please try again: ";
		}
	}

	cout << "\nTime skips until after spring break...\n";
	cin.get();
	cout << "Welcome back, " << teacher << ".";
	cin.get();
	while (true)
	{
		cout << "\nWhat activity do you want to do today?\n";
		cout << "1. Search information about a student (Linear)\n";
		cout << "2. Search information about a student (Binary)\n";
		cout << "3. Print class in order of age\n";
		cout << "4. Quit\n";

		cin >> input;
		if (input == 1)
		{
			int search;
			cout << "Student age: ";
			cin >> age; 
			search = LinearSearch(student, age);
			if (search = -1)
			{
				cout << "Error: There's no student by the age: " << age << endl;
			}
			else 
			{
				cout << "The first match was: " << student[search].name;
				cout << student[search].name << " is student number: " << search;
			}
		}

		else if (input == 4)
		{
			exit (EXIT_SUCCESS);
		}


	}


	cin.sync();
	cin.get();
	return 0;
}
On line 34, you used the assignment operator instead of comparison operator.
Haha, I'm silly... Thanks!
Edited that, but now I'm getting these results:
http://i.gyazo.com/f0a19b5c7e5b5d813e283bfccacc157e.png
same on line 114

if (search = -1)

so every search shows as no match
Oh my god... Thanks again...

I guess I was too used to using the assignment operator here..
Thanks again.
Topic archived. No new replies allowed.