Infinite loop will not stop.

This is a discussion on Infinite loop will not stop. within the C++ Programming forums, part of the General Programming Boards category; I recently made a Do-while loop in C++ with Code::Blocks while doing the tutorial about loops, and when I ran ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    4

    Infinite loop will not stop.

    I recently made a Do-while loop in C++ with Code::Blocks while doing the tutorial about loops, and when I ran it, it would not stop. I have tried clicking X, stopping the task in Task Manager, and pressing ctrl+c, but none of these will work. The window will close, but the debugger will not stop running. When I try to run another program, it says: ld.exe||cannot open output file bin\Debug\File.exe Permission denied| ||=== Build finished: 1 errors, 0 warnings ===|. I deleted the code I had entered when I ran the loop, and do not remember it. I am new to programming and would welcome any help to fix this.

    Thanks.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,794
    Since you cannot reproduce the code, there is no help that can possibly be provided to fix the code

    You probably made some classic mistake like incrementing a loop counter with a loop condition that checks if the loop counter is greater than, rather than less than, some value.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    4
    I think it was similar to this:

    Code:
     #include <iostream>
    
    using namespace std;
    
    int main()
    {
      int x;
    
      x = 0;
      x++;
      do
      {
        cout<<"Hello, world!\n";
      }
      while ( x < 3 );
      cin.get();
    }

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,794
    Ah, then you forgot to increment the counter in the loop.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Aug 2011
    Posts
    4
    Is there any way I can just delete the whole program that is looping? I don't really need it and when I try to delete it, it says it is being used and won't let me.

  6. #6
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Retribution View Post
    Is there any way I can just delete the whole program that is looping? I don't really need it and when I try to delete it, it says it is being used and won't let me.
    You want to delete the executable ...right? Just stop its running and then do so. If you're attempting to delete the source file, you need to close the ide. Also; why is your program still looping?,...didn't you follow the thread to correct it?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  7. #7
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,438
    What do you mean? stop the program when it loops uncontrollably? you can use the CTRL+break / pause combo on your keyboard, also in the task manager look for other processes that are linked to the console or debugger and stop those, but the permission denied error is reported often so try this search
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  8. #8
    Registered User
    Join Date
    Aug 2011
    Posts
    4
    Ok I fixed it. I just deleted the executable in the processes section of task manager.

    Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. infinite loop
    By leahknowles in forum C Programming
    Replies: 4
    Last Post: 03-24-2011, 03:37 PM
  2. Replies: 8
    Last Post: 07-29-2010, 01:57 PM
  3. Replies: 2
    Last Post: 06-14-2009, 11:24 PM
  4. How to stop an infinite cyle?
    By opsis in forum Linux Programming
    Replies: 4
    Last Post: 01-07-2007, 11:58 AM
  5. stays in loop, but it's not an infinite loop (C++)
    By Berticus in forum C++ Programming
    Replies: 8
    Last Post: 07-19-2005, 11:17 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21