| | |
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 |
.dll api array arrays assignment binary bitmap bmp borland c# c++ calculator char char* class code codeblocks compile compression console convert decide delayload development directshow download ebook embed embedded encryption error exam examples faq file fstream function functions game gdi+ gnu graph gui html ide insert int introduction java jni line linker linux lnk2019 math matrix maze microsoft modal multiple newbie noob numbers objects output parallel pointers pong position primenumbersinrange problem program programing programming python read recursion recursive regqueryvalueex rpg search selection sql stop store string struct superclass symbian temperature template text traverse tree tutorial url visual visualization visualstudio win32






