The use of the continue keyword


Match word(s).

If you have any questions or comments,
please visit us on the Forums.

FAQ > Explanations of... > The use of the continue keyword

This item was added on: 2003/03/14

It seems that people place continue near goto when it comes to holy wars. The question stems from whether or not continue falls into structured programming practice as well as whether a pure structured programming practice is practical in the real world.


/* if..else */
while ( ( ch = getchar() ) != EOF ) 
{
  if ( ch == ' ' ) 
  {
    /* Process whatever is left */
  }
}

/* continue */
while ( ( ch = getchar() ) != EOF ) 
{
  if ( ch != ' ' )
    continue;

  /* Process whatever is left */
}


By this train of thought, continue is perfectly suited to structured programming. However, opinions are rarely swayed by rational thought. The best advice I have heard is that continue is a tool and since there is no proof for whether its usage is correct or not, use it where it is needed and be prepared to be wrong in your decision.

Credit: Prelude

Script provided by SmartCGIs