C++ Assign fixed value to int.

Hello everybody :D

I am making a console app in MSVS 2008. I am trying to achieve something very simple, and that is to assign a fixed value to an int, but I can't.
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

#include <iostream>
#include <string>
#include <Windows.h> 


using namespace std;

int main ()
{ 

  int o = 3; //character sucking up length

  int x;


	cin >> x; 
	
	cout << endl;
	cout << endl;
	if ( x == 3 ){o == 8;}
	else {o == 7;}
	cout << o;

 cin.clear();
cin.ignore(255, '\n');
cin.get();
  
  
  return 0;
}


It compiles, but it says "o == 8; and o == 7; has no effect"

Is there a command that clears the original number and replaces it with that fixed value?

I would appreciate any help,

Muhasaresa
== is the operator for a logical test.

o == 8 tests to see if o has the value 8.

If you want to make o equal 8, use o=8

I am amazed that you can use int o = 3; to set o to 3, and then forget how to set the value a few lines later.
Thanks :D
Topic archived. No new replies allowed.