登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

面包会有的

... ...

 
 
 

日志

 
 

MSDN:While语句  

2008-05-19 12:03:13|  分类: VC++ |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

The C while Statement

The while statement lets you repeat a statement until a specified expression becomes false.
//while语句让你重复一个语句直到一个指定的表达式变成否

Syntax

iteration-statement :

while ( expression ) statement

The expression must have arithmetic or pointer type. Execution proceeds as follows:

  1. The expression is evaluated.

  2. If expression is initially false, the body of the while statement is never executed, and control passes from the while statement to the next statement in the program.

    If expression is true (nonzero), the body of the statement is executed and the process is repeated beginning at step 1.

The while statement can also terminate when a break, goto, or return within the statement body is executed. Use the continue statement to terminate an iteration without exiting the while loop. The continue statement passes control to the next iteration of the while statement.

This is an example of the while statement:

while ( i >= 0 ) {    string1[i] = string2[i];    i--;}

This example copies characters from

string2

to

string1

. If

i

is greater than or equal to 0,

string2[i]

is assigned to

string1[i]

and

i

is decremented. When

i

reaches or falls below 0, execution of the while statement terminates.

  评论这张
 
阅读(838)| 评论(0)

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018