Thread: continue

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    88

    continue

    i dont really understand what the continue keyword does but i think it basically tells a loop to continue (from the short man page on it). If this is right, is it a good keyword to use or no because it kinda seems like goto to me (but what do i know). thx for answers.

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    the continue keyword is similar to break except that instead of completely breaking out of the loop, it continues on to the loop's next part (fairly obvious). Note that continue can't be used in switch statements.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    More specifically, continue will cause execution to jump back to the beginning of the loop, skipping whatever may have come after it...

    ie:


    Code:
    int
     stringlen(const char * str)
    {
      int count = 0;
      int i = 0;
          while(1)
        {
               if( str[i++] != 0 )
             {
               ++count;
               continue;
             }
           break; //...this won't happen if str[i] != 0...    
        } 
     return count;
    }
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    More information about continue..

    Can be found here

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    88
    thx i get it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 11-03-2008, 09:48 PM
  2. Continue and switch
    By camzio in forum C Programming
    Replies: 10
    Last Post: 10-04-2008, 08:31 AM
  3. switch - continue
    By DavidP in forum C Programming
    Replies: 2
    Last Post: 06-24-2004, 10:09 AM
  4. Press enter to continue... beginner code
    By rox in forum C Programming
    Replies: 17
    Last Post: 12-02-2003, 05:32 PM
  5. continue in while loops
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 03-04-2002, 10:58 PM