Thread: loops ?

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    loops ?

    Hello,

    I am kinda new to C++ and have a couple of ?s:

    what does for(;;) mean ??

    the usual way I have seen is for (int i =1; i<2, i++) .


    Also, I have encountered the term "stubs", what are these??

    Finally, what are daemons??


    Thanks for the help!

  2. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    for(;;) is an infinite loop. There is no initialization, no end condition, and no increment.

    This is similar to a while(1) loop, which is a more common way of doing the same thing.

    I suppose the reason that you see for(;;) in text books is to show that each of these paramaters is optional.

    The following are from FOLDOC:
    daemon

    stub

    [EDIT]
    You have to include a way to get out of the empty for-loop. You can use break; Or, return; if you want to exit the loop and the current function.
    Last edited by DougDbug; 07-24-2003 at 07:11 PM.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The empty for loop means in effect it never ends. With for loops, you can leave out any of its parameters. If it has none, then it has no stop condition, so it just keeps going.

    [edit]Curses, foiled again![/edit]

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by DougDbug
    for(; is an infinite loop. There is no initialization, no end condition, and no increment.

    This is similar to a while(1) loop, which is a more common way of doing the same thing.
    for(; looks really ugly. I'd always use while(true)...

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    infinite loops usually mean you could have thought through the design a little better. I don't usually like to see while(1) or for(;;). I mean you might as well just use a goto with that mentality!
    Last edited by FillYourBrain; 07-25-2003 at 07:37 AM.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loops Trouble
    By rlframpton in forum C Programming
    Replies: 2
    Last Post: 04-17-2009, 01:08 AM
  2. Too many loops D:
    By F5 Tornado in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2007, 01:18 AM
  3. recoursion or loops?
    By Mecnels in forum C++ Programming
    Replies: 2
    Last Post: 01-14-2002, 12:09 PM
  4. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 04:28 PM
  5. for loops - newbie q's
    By Narciss in forum C Programming
    Replies: 8
    Last Post: 09-26-2001, 02:44 AM