By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

Looping without a loop

cypherzero
P: 15
In debug-step-through mode the first three lines of the following code just keep looping. Anyone any ideas as to why this would happen?! Cheers.

Expand|Select|Wrap|Line Numbers
  1. int r = GetRValue(colour) + (rand() % GetRValue(colourvar));
  2. int g = GetGValue(colour) + (rand() % GetGValue(colourvar));
  3. int b = GetBValue(colour) + (rand() % GetBValue(colourvar));
  4. if (r > 255) r = 255;
  5. if (g > 255) g = 255;
  6. if (b > 255) b = 255;
  7. return RGB(r, g, b);
  8.  
'colour' and 'colourvar' are just unsigned longs and GetR/G/BValue are just simple Window's Macros (#define GetRValue(rgb) (LOBYTE(rgb)) //etc...)
Aug 12 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
In debug-step-through mode the first three lines of the following code just keep looping. Anyone any ideas as to why this would happen?! Cheers.
In what way does that code 'loop'? Does it jump back to line 1 after executing
line 3? Are you accidentally invoking recursion? (what's the name of your
method that executes this snippet of code?)

kind regards,

Jos
Aug 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.