passing variables

I have the following code but I need to pass the result back into the code that it was called from, can anyone help me out? Here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
someFunction(){.....

fiftyfifty();
// i need the result from fiftyfifty right here
if (fiftyfifty() = 1)
playerAttack();
else
compAttack();
		}
}


int fiftyfifty(){
int randy;	
srand((unsigned)time(0));
for(int index=0; index<1; index++){
randy = (rand()%2)+1;
}
			
return randy;
}

I might be mistaken but if you declare some new variable, say "x", and have:

1
2
3
4
5
6
x = fiftyfifty();
// i need the result from fiftyfifty right here
if (x == 1)
playerAttack();
else
compAttack();


When you "return randy" it will return the value to x, so you can use the value in the comparison.

One quick question: Is this C or C++? Do you need "==" in your "if" statement?
lol hah, it was just a syntax error. I was in fact using "=" instead of "==". Thanks for the reply though, much appreciated.
Topic archived. No new replies allowed.