| | |
Need some help with if statements
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 29
Reputation:
Solved Threads: 0
I need to have a function like this:
if (x == 1){
...
}
do some amazing things.
I need it to check to see if x == 1 through 380 or more.
But I really don't want to waste 4 hours doing this:
if (x == 1 || x == 2 || x == 3 || ... || x == 380)
I am using a mouse peripheral and I need it to check to see if the mouse x/y coords are, when clicked, in a certian place on the screen. So essentially "x == 1" is the #1 pixel on the x coords.
If someone can help me find a way to do this faster, THANKS!
if (x == 1){
...
}
do some amazing things.
I need it to check to see if x == 1 through 380 or more.
But I really don't want to waste 4 hours doing this:
if (x == 1 || x == 2 || x == 3 || ... || x == 380)
I am using a mouse peripheral and I need it to check to see if the mouse x/y coords are, when clicked, in a certian place on the screen. So essentially "x == 1" is the #1 pixel on the x coords.
If someone can help me find a way to do this faster, THANKS!
0
#2 Nov 1st, 2009
you can easily perform a test on an entire range of values:
C++ Syntax (Toggle Plain Text)
//If 'x' is greater than or equal to 1 AND 'x' is less than or equal to 380 if(x >= 1 && x <= 380) { //Do amazing things }
Last edited by Clinton Portis; Nov 1st, 2009 at 1:04 am.
0
#3 Nov 1st, 2009
C++ Syntax (Toggle Plain Text)
if ( x > 0 && x <= 380 ) { }
Я из Молдавии. Говорю на Русском.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Finding Struct highest and lowest!
- Next Thread: Game of Crap
| Thread Tools | Search this Thread |
Tag cloud for c++
.dll 3d api array arrays assignment based binary bitmap c# c++ calculator char char* class compile compression console data delayload development download email embed embedded encryption engine error evc exam examples faq file fstream function functions game graph guess gui html ifstream int introduction java jni keyboard linker linux lnk2019 math maze microsoft modal newbie noob number output partnership pause php pointers primenumbersinrange problem professor program programming project projects python question read recursion recursive richedit rpg search send sql string strings struct studio subclass system temperature template templates test text timer traverse tree university url variable visual visualstudio void win32






