分号的作用 [英] role of semicolon

查看:79
本文介绍了分号的作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< stdio.h>

int main(无效)

{

int i = 0;

++ i; ++ i;

printf(" i equals%d \ n",i);

返回0;

}


我一直在试图确定分号的大量和多种用途

in c。这不是一件容易的事。 Q1)上述编程是否符合要求?我的

编译器很喜欢它。 Q2)若然,主要有多少陈述?

MPJ

#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I''ve been trying to determine the great and manifold uses of the semicolon
in c. It''s not such an easy thing. Q1) Is the above prog conforming? My
compiler likes it just fine. Q2) If so, how many statements are in main?
MPJ

推荐答案

" Merrill&米歇尔" <是******** @ comcast.net>在消息中写道

新闻:lL ******************** @ comcast.com ...
"Merrill & Michele" <be********@comcast.net> wrote in message
news:lL********************@comcast.com...
# include< stdio.h>
int main(void)
{i / 0;
++ i; ++ i;
printf(i等于%d \ n,i);
返回0;
}
我一直在尝试确定
分号在c中的重要用途。这不是一件容易的事。 Q1)以上程序是否符合要求?我的编译器很喜欢它。


是。

Q2)如果是,主要有多少陈述?
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I''ve been trying to determine the great and manifold uses of the
semicolon in c. It''s not such an easy thing. Q1) Is the above prog
conforming? My compiler likes it just fine.
Yes.
Q2) If so, how many statements are in main?




就语言语法而言,main中有四个语句:

两个预增量和对printf()的调用(都是

表达式语句) ,加上返回(这是一个跳转语句)。 int i

= 0;"是一个声明,而不是一个声明,尽管代码将通常由于存在初始化而生成



部分定义main是复合语句,从''{''到

''}''包含。复合语句是一个声明,所以如果你算上

,那么答案就是五。


再根据语言语法,使用分号似乎是:

- 终止声明,

- 终止表达式语句(表达式语句可能包含

只有终止' ';''),

- 终止do..while循环(一种迭代语句),

- 分隔for循环顶部的三个表达式(另一种类型

of iteration-statement),和

- 终止跳转语句(goto,continue,break,return)。


可以更正...


Alex



In terms of the language grammar, there are four statements inside main: the
two pre-increments and the call to printf() (which are all
expression-statements), plus the return (which is a jump-statement). "int i
= 0;" is a declaration, not a statement, despite the fact that code will
normally be generated due to the presence of an initialiser.

Part of the definition of main is the compound-statement, from the ''{'' to
the ''}'' inclusive. A compound-statement is a statement, so if you count that
too, then the answer is five.

Again according to the language grammar, uses of semi-colon seem to be:
- terminating declarations,
- terminating expression-statements (expression statements may consist of
only the terminating '';''),
- terminating do..while loops (a type of iteration-statement),
- seperating the three expressions at the top of a for loop (another type
of iteration-statement), and
- terminating jump-statements (goto, continue, break, return).

Open to correction...

Alex




" Alex Fraser" < me@privacy.net>在消息中写道

news:32 ************* @ individual.net ...

"Alex Fraser" <me@privacy.net> wrote in message
news:32*************@individual.net...
" Merrill&米歇尔" <是******** @ comcast.net>在消息中写道
新闻:lL ******************** @ comcast.com ...
"Merrill & Michele" <be********@comcast.net> wrote in message
news:lL********************@comcast.com...
#include< stdio .h>
int main(void)
{i / 0;
++ i; ++ i;
printf(i等于%d \ n,i);
返回0;
}
我一直在尝试确定
分号在c中的重要用途。这不是一件容易的事。 Q1)以上程序是否符合要求?我的编译器很喜欢它。
是的。
#include <stdio.h>
int main(void)
{
int i = 0;
++ i; ++ i;
printf("i equals %d\n", i);
return 0;
}

I''ve been trying to determine the great and manifold uses of the
semicolon in c. It''s not such an easy thing. Q1) Is the above prog
conforming? My compiler likes it just fine.
Yes.
Q2)如果是这样,主要有多少语句?
Q2) If so, how many statements are in main?



语言语法的术语,主要有四个语句:



In terms of the language grammar, there are four statements inside main:



两个预增量和对printf()的调用(都是
表达式语句),加上返回(这是一个跳转语句)。 int
i = 0;是一个声明,而不是一个声明,尽管代码通常会由于存在初始化而生成。

main的定义部分是复合语句,来自''{''
''}''包含在内。复合语句是一个声明,所以如果你也计算
,那么答案是五。

再次根据语言语法,使用分号似乎是:
- 终止声明,
- 终止表达式语句(表达式语句可能只包含终止'';''),
- 终止do..while循环(一种类型) of iteration-statement),
- 将三个表达式分隔在for循环的顶部(另一个类型的迭代语句),并且
- 终止跳转语句(goto,continue,休息,返回)。

打开校正...


the two pre-increments and the call to printf() (which are all
expression-statements), plus the return (which is a jump-statement). "int i = 0;" is a declaration, not a statement, despite the fact that code will
normally be generated due to the presence of an initialiser.

Part of the definition of main is the compound-statement, from the ''{'' to
the ''}'' inclusive. A compound-statement is a statement, so if you count that too, then the answer is five.

Again according to the language grammar, uses of semi-colon seem to be:
- terminating declarations,
- terminating expression-statements (expression statements may consist of
only the terminating '';''),
- terminating do..while loops (a type of iteration-statement),
- seperating the three expressions at the top of a for loop (another type
of iteration-statement), and
- terminating jump-statements (goto, continue, break, return).

Open to correction...




感谢您的慷慨细节。我看到的唯一密切关系是

分号拼写没有连字符。 MPJ



Thank you for the generous detail. The only germane correction I saw is
that semicolon is spelled without a hyphen. MPJ


2004年12月17日星期五14:37:53 +0000,Alex Fraser写道:


....
On Fri, 17 Dec 2004 14:37:53 +0000, Alex Fraser wrote:

....
main的定义部分是复合语句,从''{''到
''}''包含。复合语句是一个声明,所以如果你计算
,那么答案是五。
Part of the definition of main is the compound-statement, from the ''{'' to
the ''}'' inclusive. A compound-statement is a statement, so if you count that
too, then the answer is five.




有趣的是这是一个例子(并且是唯一的一)当一个化合物

声明ISN''一个声明。检查语法。


劳伦斯



Interestingly this is an example (and the only one) of when a compound
statement ISN''T a statement. Check the grammar.

Lawrence


这篇关于分号的作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆