Trouble with reading file

So I have three .txt files: data.txt, medium.txt, and hard.txt. Here is my code

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
        ifstream input;

	int level;
	cout<<"Which level would you like to play? \n"
		<<"1.Easy"<<endl
		<<"2.Medium"<<endl
		<<"3.Hard";
	cin>>level;

	if(level = 1)
	{
		input.open("data.txt");
	}

	else if(level = 2)
	{
		input.open("medium.txt");
	}

	else if (level = 3)
	{
		input.open("hard.txt");
	}


	int r = 0;
	int c = 0;

	input>>r; //gets first number in file
	input>>c; //gets second number in file

	input.close();


The data.txt file has the coordinates (3,4)
The medium.txt file has the coordinates (4,4)
The hard.txt file has the coordinates (5,5)

However, when I print out the r and c variables, as the coordinates, they always print out 3,4, no matter what level I choose.

Any idea why?
level = 1 assigns 1 to level
level == 1 compares 1 to level

Sweet so I'm pretty much the stupidest person ever. Guess I just needed a second eye. Thank you!
Topic archived. No new replies allowed.