looping

This is a discussion on looping within the C++ Programming forums, part of the General Programming Boards category; How can make my code to loop without defining any conditions. Just to loop no matter what?...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    16

    looping

    How can make my code to loop without defining any conditions. Just to loop no matter what?

  2. #2
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Well you could simply use *looks around, leans in, whispers* goto
    *ducks*

    However I would simply place a true constant in the parameters such as
    Code:
    #include <stdio.h>
    
    
    void Foo(void); //prototype
    
    int main(void) {
    
    	do{  
    		Foo();
    	}while(1);
        return 0;
    }
    void Foo(void) { //function definition
    
        printf("Hello world\n");
    }
    This works for all types of loops. You can use a for loop and simply not increment your parameter as well:
    Code:
    for(int i = 0; i< 10; )
    What exactly are you trying to accomplish?
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    or
    Code:
    for(;;)
    {
       ...
    }

  4. #4
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149
    use 'goto'

    blow me ... ...

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Do not use 'goto'. There are a very few rare occasions when it is acceptable to use, and this is NOT one of them. This is a perfect example of improper 'goto' usage. Go with sand_man or andyhunter's suggestions:
    Code:
    while(1)
    {
    }
    while(true)
    {
    }
    for(;;)
    {
    }
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    25
    the for(; works...

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    25
    *._. grrr...evil smiley i mean ( ; ; )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wierd looping effect after exporting 3ds to .x annimation
    By Anddos in forum Game Programming
    Replies: 3
    Last Post: 01-06-2009, 12:43 PM
  2. problems with prototype function looping
    By dezz101 in forum C Programming
    Replies: 5
    Last Post: 04-29-2008, 06:03 AM
  3. looping went berserk
    By miryellis in forum C Programming
    Replies: 7
    Last Post: 09-21-2004, 01:59 PM
  4. Looping questions
    By Peyote in forum C++ Programming
    Replies: 3
    Last Post: 09-15-2003, 11:01 PM
  5. looping and input
    By Kinasz in forum C Programming
    Replies: 2
    Last Post: 03-17-2003, 06:12 AM

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