| | |
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 29 Days Ago
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; 29 Days Ago at 1:04 am.
0
#3 29 Days Ago
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 |
.so api array asp beginner binary bitmap bmp borland c# c++ char char* class client codeblocks compression console data database decide delayload delete development download ebook email encryption engine equation error exam examples faq file floatingpoint fstream function functions game gdi+ graph guess input insert int introduction java jni linux lnk2019 math maze method modal multiple music mysql newbie node numbers opengl output parallel performance pong primenumbersinrange problem professor program programmer programming python read recursion recursive registry space sql stop stream string struct studio superclass system template text timer toolkit traverse tree tutorial url vector visual web win32 win32api wxwidgets






