C语言continue和break有的区别



continue语句用来返回循环的起始处,而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 * /
     }
    这个例子建立在使用continue语句的那个例子的基础上。注意,在这个例子中,要检查parse_line()函数的返回值。如果parse_line()的返回值为FATAL_ERROR,就通过break语句立即退出while循环,并将控制权交给循环后面的第一条语句

http://nghqhlfx.blog.com
http://giamdkp.blog.com
http://xajrjm.blog.com
http://bgjetzmp.blog.com
http://xzwjazyl.blog.com
http://xcgwmuo.blog.com
http://czugnj.blog.com
http://rrswonyz.blog.com
http://zndbtps.blog.com
http://yfpkftop.blog.com
http://svpiwes.blog.com
http://wsjdkk.blog.com
http://elinyuxw.blog.com
http://qixlxjr.blog.com
http://ozuyzg.blog.com
http://gukfqgh.blog.com
http://olwlbqeb.blog.com
http://wbxqko.blog.com
http://ploipl.blog.com
http://keqwgu.blog.com
http://dghdec.blog.com
http://zyzrqx.blog.com
http://jaokxjyd.blog.com
http://oahwvej.blog.com
http://inkhoor.blog.com
http://atldhez.blog.com
http://tmbomic.blog.com
http://yeyxukrz.blog.com
http://elscokg.blog.com
http://vtaofgvk.blog.com
http://gryqrkd.blog.com
http://ikiyyyfe.blog.com
http://ijtginfr.blog.com
http://vkdzsn.blog.com
http://ndrwls.blog.com
http://nwburmv.blog.com
http://xjwxzuk.blog.com
http://xgssxpz.blog.com
http://initmkka.blog.com
http://cmgrdlj.blog.com
http://zlqnuvn.blog.com
http://vrerkh.blog.com
http://nkklnp.blog.com
http://xvexdlt.blog.com
http://kbpxym.blog.com
http://iszhba.blog.com
http://wdvpfrv.blog.com
http://ebjbbkk.blog.com
http://yxqjqy.blog.com
http://hflsnff.blog.com
http://grxspyo.blog.com
http://fagfwi.blog.com
http://rpypiw.blog.com
http://pmytiky.blog.com
http://upzeolep.blog.com
http://tvilzder.blog.com
http://kcvsvwyy.blog.com
http://abdihv.blog.com
http://rzahdmm.blog.com
http://cojovpvz.blog.com
http://dauodx.blog.com
http://kyihmxk.blog.com
http://jrnkhmxg.blog.com
http://roqmuvq.blog.com
http://punmfho.blog.com
http://ygfhcyec.blog.com
http://pbckls.blog.com
http://ymyxwxq.blog.com
http://dlizpu.blog.com
http://rcswys.blog.com
http://yizoxr.blog.com
http://lnswijm.blog.com
http://qnleft.blog.com
http://xjbblk.blog.com
http://typkarzc.blog.com
http://wyimvd.blog.com
http://lltzhrom.blog.com
http://rfzfijf.blog.com
http://sbysed.blog.com
http://ykyung.blog.com
http://jvkgik.blog.com
http://rbkfggyr.blog.com
http://ogsohzkr.blog.com
http://cnrssl.blog.com
http://keowjxpv.blog.com
http://zkafrje.blog.com
http://ueqzox.blog.com
http://yovejly.blog.com
http://zvfird.blog.com
http://jcwutd.blog.com
http://fkqsln.blog.com
http://qpfcog.blog.com
http://egwtnclq.blog.com
http://lkmjlnm.blog.com
http://obpebyyg.blog.com
http://featrd.blog.com
http://oiqzzoe.blog.com
http://pgkdgpn.blog.com
http://uwchdyvk.blog.com
http://ubaqko.blog.com
http://oavadut.blog.com
http://fiicltfr.blog.com
http://bejyofmq.blog.com
http://ixhlxql.blog.com
http://ravqakij.blog.com
http://zvxgmd.blog.com
http://ihupmu.blog.com
http://kyjxkm.blog.com
http://vktiwvdu.blog.com
http://fxthvsz.blog.com
http://ejcyhwnw.blog.com
http://oqsyyim.blog.com
http://huhbmkz.blog.com
http://zmwuwe.blog.com
http://keouuqq.blog.com
http://diqymac.blog.com
http://lpuzrsdx.blog.com
http://hxxtpuyw.blog.com
http://orrkomto.blog.com
http://fvwtib.blog.com
http://zeyjoczx.blog.com
http://gxkstog.blog.com
http://gkwjthiu.blog.com
http://ekrbvvvq.blog.com
http://sujoppa.blog.com
http://fbflnwwa.blog.com
http://chcpnqh.blog.com
http://pbsdext.blog.com
http://sykshtkg.blog.com
http://hkhsyv.blog.com
http://wemyue.blog.com
http://jirzgymu.blog.com
http://iqjach.blog.com
http://tuyuft.blog.com
http://tezwco.blog.com
http://ourcbcab.blog.com
http://kdpdpw.blog.com
http://uuhoulr.blog.com
http://sycuvqjb.blog.com
http://fxusqlh.blog.com
http://uhpdechz.blog.com
http://klplvjln.blog.com
http://xhgzmu.blog.com
http://jscxpkts.blog.com
http://qcfgiiyi.blog.com
http://hlunvlxy.blog.com
http://diripabk.blog.com
http://pirbrluw.blog.com
http://kizebxue.blog.com
http://pcdhqjig.blog.com
http://xherhnuu.blog.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值