Making two infinite loops inside the other?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cosmos22
    New Member
    • Feb 2008
    • 9

    Making two infinite loops inside the other?

    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.



    Code:
    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);
    }
    CloseHandle(hcd);
    
    return 0;
    }
    Last edited by Ganon11; Feb 19 '08, 07:27 PM. Reason: Please use the [CODE] tags provided.
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    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.

    Comment

    • cosmos22
      New Member
      • Feb 2008
      • 9

      #3
      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_E JECT_MEDIA, NULL, 0, NULL, 0,
      &d, NULL);

      DeviceIoControl (hcd, IOCTL_STORAGE_L OAD_MEDIA, NULL, 0, NULL, 0,
      &d, NULL);
      }


      The while condition
      while(1)
      {
      code
      }
      Makes it loop again and again.

      Comment

      • Ganon11
        Recognized Expert Specialist
        • Oct 2006
        • 3651

        #4
        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?

        Comment

        Working...