C语言continue和break有的区别

ontinue语句用来返回循环的起始处,而break语句用来退出循环。 例如,下例中就有一条典型的continue语句:
    while(!feof(infile))
    {
       fread(inbuffer,80,1,infile);/*read in a line from input file*/
       if(!strncmpi(inbuffer,"REM",3))  /*check if it is
                                             a comment line*/
       continue;    /*it's a comment,so jump back to the while()*/
       else
      parse_line();    /*not a comment—parse this line*/
    }
上例读入一个文件并对其进行分析。“REM(remark的缩写)”用来标识正在被处理的文件中的一个注释行。因为注释行对程序不起任何作用,所以可以跳过它。在读入输入文件的每一行时,上例就把该行的前三个字母与"REM"进行比较。如果匹配,则该行就是注释行,于是就用continue语句返回到while语句,继续读入输入文件的下一行;否则,该行就是一条有效语句,于是就调用parse_line()函数对其进行分析。

break语句用来退出循环。 下面是一个使用break语句的例子:
while (! feof(infile))
     fread(inbuffer,80,1,infile) ;/* read in a line from input file * /
     if (! strncmpi (inbuffer,"REM",3))  / * check if it is
                                                           a comment line * /
           continue;       /* it's a comment, so jump back to the while() * /
     else
     {
           if (parse_line()==FATAL_ERROR)   / * attempt to parse
                                                                    this line * /
              break;                 /* fatal error occurred,so exit the loop * /

     }

http://v.17173.com/playlist_16243005.html
http://v.17173.com/playlist_16244048.html
http://v.17173.com/playlist_16244589.html
http://v.17173.com/playlist_16245740.html
http://v.17173.com/playlist_16246511.html
http://v.17173.com/playlist_16276445.html
http://v.17173.com/playlist_16275379.html
http://v.17173.com/playlist_16274196.html
http://v.17173.com/playlist_16272743.html
http://v.17173.com/playlist_16271745.html
http://v.17173.com/playlist_16270694.html
http://v.17173.com/playlist_16269747.html
http://v.17173.com/playlist_16268962.html
http://v.17173.com/playlist_16267988.html
http://v.17173.com/playlist_16266881.html
http://v.17173.com/playlist_16265728.html
http://v.17173.com/playlist_16264745.html
http://v.17173.com/playlist_16263755.html
http://v.17173.com/playlist_16262692.html
http://v.17173.com/playlist_16260273.html
http://v.17173.com/playlist_16250327.html
http://v.17173.com/playlist_16249446.html
http://v.17173.com/playlist_16248725.html
http://v.17173.com/playlist_16248141.html
http://v.17173.com/playlist_16247142.html
http://v.17173.com/playlist_16301211.html
http://v.17173.com/playlist_16299899.html
http://v.17173.com/playlist_16298388.html
http://v.17173.com/playlist_16297123.html
http://v.17173.com/playlist_16296085.html
http://v.17173.com/playlist_16294578.html
http://v.17173.com/playlist_16293492.html
http://v.17173.com/playlist_16292032.html
http://v.17173.com/playlist_16290619.html
http://v.17173.com/playlist_16289611.html
http://v.17173.com/playlist_16288604.html
http://v.17173.com/playlist_16286938.html
http://v.17173.com/playlist_16285846.html
http://v.17173.com/playlist_16284744.html
http://v.17173.com/playlist_16283600.html
http://v.17173.com/playlist_16282325.html
http://v.17173.com/playlist_16281018.html
http://v.17173.com/playlist_16279921.html
http://v.17173.com/playlist_16279035.html
http://v.17173.com/playlist_16277617.html
http://v.17173.com/playlist_16324284.html
http://v.17173.com/playlist_16323278.html
http://v.17173.com/playlist_16322226.html
http://v.17173.com/playlist_16321011.html
http://v.17173.com/playlist_16320132.html
http://v.17173.com/playlist_16319146.html
http://v.17173.com/playlist_16318138.html
http://v.17173.com/playlist_16317154.html
http://v.17173.com/playlist_16316170.html
http://v.17173.com/playlist_16315099.html
http://v.17173.com/playlist_16313923.html
http://v.17173.com/playlist_16313062.html
http://v.17173.com/playlist_16311883.html
http://v.17173.com/playlist_16310039.html
http://v.17173.com/playlist_16308938.html
http://v.17173.com/playlist_16307556.html
http://v.17173.com/playlist_16306309.html
http://v.17173.com/playlist_16305034.html
http://v.17173.com/playlist_16303450.html
http://v.17173.com/playlist_16302296.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值