Connecting Tech Pros Worldwide Forums | Help | Site Map

Making two infinite loops inside the other?

Newbie
 
Join Date: Feb 2008
Posts: 9
#1: Feb 19 '08
The following code below shows an example of a infinite while loop. I was wondering how I would incorperate another infinite loop into this , without ruining the actions inside of it. I would like to use this in the second loop

SetCursorPos( X, Y );

Thank you.



Expand|Select|Wrap|Line Numbers
  1. while(1)
  2. {
  3.    DWORD d = 0;
  4.    DeviceIoControl(hcd, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &d, NULL);
  5.  
  6.    DeviceIoControl(hcd, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0, &d, NULL);
  7. }
  8. CloseHandle(hcd);
  9.  
  10. return 0;
  11. }

Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,428
#2: Feb 19 '08

re: Making two infinite loops inside the other?


When does your infinite loop end? Usually if you have a loop whose condition is simply 1 or true, you have a break statement, but I don't see anything.
Newbie
 
Join Date: Feb 2008
Posts: 9
#3: Feb 19 '08

re: Making two infinite loops inside the other?


Quote:

Originally Posted by Ganon11

When does your infinite loop end? Usually if you have a loop whose condition is simply 1 or true, you have a break statement, but I don't see anything.

while(1)
{
DWORD d = 0;
DeviceIoControl(hcd, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0,
&d, NULL);

DeviceIoControl(hcd, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0,
&d, NULL);
}


The while condition
while(1)
{
code
}
Makes it loop again and again.
Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,428
#4: Feb 19 '08

re: Making two infinite loops inside the other?


I realize this, but infinite loops are, generally, bad. This program will never finish. It will never exit, get outside the loop, etc...

So in order to stop this process, you will have to use Ctrl+c, or some external method of stopping the program, which doesn't allow it to quit normally, which is bad for your computer. So I must ask, why do you want this loop to continue indefinitely?
Reply