Console Class; Creating colorful rectangles

Alright, so I've worked out how to write my program to create "beautiful" rectangles of various colors with a user specified character. The problem I'm having is with this little bit of code.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
		cout << "Enter drawing chracter: ";
		cin >> drawChar;

		cout << "Background color is black\n";
		cout << "Would you like to change it? [y/n] ";
		cin >> background;

		background = tolower(background);

		Console::SetWindowSize(width < 35 ? 35: width + 6, height + 6);
		Console::Clear();

		if( background = 'n')
		{
			Console::BackgroundColor = ConsoleColor::Black;
		}
		else if (background = 'y')
		{
			Console::BackgroundColor = ConsoleColor::White;
		}// end if


Even if I enter y when asked if I would like to change background color it does not change to white. The code to change the background color works fine without the if statement. I looked through it quite a long time and I have no idea why it won't work. A thought I had was that there was stuff lying around in the buffer from previous user input. I don't know if that is possible or where it would some from though. Any help appreciated. More code available upon request. Thank you!
if( background = 'n')

else if (background = 'y')
Last edited on
I don't really see what you are trying to get at. It appears to me as if you copy pasted my code. I believe they are the correct way. If not I tested it both ways so it's not the problem of a swapped y and n. Thank you though.
Your code: =

---

You need: ==

---

Don't forget your equality symbols
Ah right. Thank you! My professor warned us about that a long time a go too. I appreciate the help!
Topic archived. No new replies allowed.