More C programming questions ...

Ben Duncan bns
Tue Feb 15 10:55:26 PST 2005


Can a "break" be used to bust out of a for loop:

example:

int idx = 0 ;
int DONEGOOD = 0 ;
int numberitems = 64 ;   /* Limit items we can have to 64 */
char string[256] ;       /* MAKE big enuff so we do not overflow
                             mydata in the file will always be 32  */

for (idx = 0 ; idx < numberitems ; idx++ )
{
     gogetmydata( string ) ;
     if ( strncmp( string, "ITEMID", 6) == 0 )
        {
          DONEGOOD = 1 ;
          break ;
         }
}


AND/OR, is there a better way of doing this ?

thanks ...


-- 
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor



More information about the Linux-users mailing list