More C programming questions ...
Collins Richey
crichey
Tue Feb 15 11:28:26 PST 2005
On Tue, 15 Feb 2005 09:53:41 -0600, Ben Duncan <bns at meta3.net> wrote:
> 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 ?
>
1. Yes
2. No, this is perfectly normal code.
--
Collins
More information about the Linux-users
mailing list