Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Explain something to me

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Mon Aug 13, 2007 7:24 pm    Post subject: Explain something to me Reply with quote

What does this code mean? Its in C/C++.
Code:
Z = (x>y) ? Y : x;


Just replace the X, Y, and Z with variables.

Here is another bit of that code.

Code:
int soldiers = 5;
int tanks = 10;
int max = (b>1) ? b : a;
int min = (b<a) ? b : a;
cout << "The largest value is: " << max << end1;
cout << "The smallest value is " << min << end1;


An explanation would be nice.

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Aug 13, 2007 7:40 pm    Post subject: Reply with quote

? : are Condition operators
so its liek this

(test expression) ? if-true do this : if-false do this

Code:
int soldiers = 5;  //int soldiers declaired as 5
int tanks = 10;  //tanks declaired as 10
int max = (b>1) ? b : a; // max: if b is greater then 1 then b = max, else 1 = max
int min = (b<a) ? b : a; //min: if b is smaller then a then b = min, else a = min
cout << "The largest value is: " << max << end1; //output of the max, declaired above
cout << "The smallest value is " << min << end1; //output of the min declaired above

// This Code doesnt make sense, but i assume theres more.


u can use this, or u can use the conditional if and else.

they basicly do the same thing except this assigns easier then writing another code.

Edit:

btw, don't forget about C++'s case sensitive

Code:
Z = (x>y) ? Y : x;


should be

Code:
Z = (x>y) ? y : x;


Z has to be upercase when u call it

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites