何时使用;何时使用 [英] when to use ; and when to use ,

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

问题描述

任何声明,例如

printf(" abc");

scanf("%d"& x);

a = 20;

可以替换为

printf(" abc"),scanf("%d"& x),a = 20;


所以我们什么时候应该使用;当我们使用时,

Any statements like
printf("abc");
scanf("%d",&x);
a=20;
can be replaced by
printf("abc"), scanf("%d",&x), a=20;

So when should we use ; and when sould we use ,

推荐答案

在文章< 11 ************** ********@o11g2000prd.googlegroups .com> ;,

Ravi< ra ********* @ gmail.comwrote:
In article <11**********************@o11g2000prd.googlegroups .com>,
Ravi <ra*********@gmail.comwrote:

>任何声明,例如

printf(" abc");

scanf("%d",& x);

a = 20;
可替换为

printf(" abc"),scanf("%d"& x),a = 20;

我们什么时候应该使用;当我们使用时,
>Any statements like
printf("abc");
scanf("%d",&x);
a=20;
can be replaced by
printf("abc"), scanf("%d",&x), a=20;

So when should we use ; and when sould we use ,



使用;当你希望人们能够理解你的代码时。


当你只希望编译器能够理解你的代码时使用。

dave

(有些地方使用它是有用和合理的,但是你好吗<
一段时间不会碰到那些)


-

Dave Vandervies dj ****** @ csclub .uwaterloo.ca

PJ Plauger有正当理由[...]虽然我会说那是

更多与他的客户有关的影响小于明智的。

- 在comp.lang.c中删除Gordon

Use ; when you want people to be able to understand your code.

Use , when you only want the compiler to be able to understand your code.
dave
(there are places where it''s useful and reasonable to use ,, but you
won''t be running into those for a while)

--
Dave Vandervies dj******@csclub.uwaterloo.ca
P.J. Plauger has a valid reason [...] although I would say that was
more to do with his customers being less than sensible.
--Flash Gordon in comp.lang.c




" Ravi" < ra ********* @ gmail.comwrote in message

news:11 ********************* *@o11g2000prd.googlegr oups.com ...

"Ravi" <ra*********@gmail.comwrote in message
news:11**********************@o11g2000prd.googlegr oups.com...

任何语句如

printf(" abc");

scanf("%d"& x);

a = 20;

可以替换为

printf( abc,scanf("%d"& x),a = 20;


所以我们何时应该使用;当我们使用时,

Any statements like
printf("abc");
scanf("%d",&x);
a=20;
can be replaced by
printf("abc"), scanf("%d",&x), a=20;

So when should we use ; and when sould we use ,
#



惯例是对逗号运算符进行极其轻松的使用,并且每个地方使用
单独操作,用分号分隔

语句。

没有特别的原因,这只是惯例。早期的

它可能会让编译器变得更容易

,因为以逗号分隔的列表也是一个表达式,但这几乎不是什么? b $ b适用于现代机器。


-

免费游戏和编程好东西。
http://www.personal.leeds.ac.uk/~bgy1mm

The convention is to make extremely light use of the comma operator and
place each operation on a line of its own, made into a statement by
separating with semicolons.
There is no particular reason for this, it is just the convention. In the
early days it might have made things a little easier for the compiler
because a comma-separated list is also an expression, but that hardly
applies on a modern machine.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm


Ravi说:
Ravi said:

任何语句如

printf(" abc") ;

scanf("%d"& x);

a = 20;

可以替换为

printf(" abc"),scanf("%d"& x),a = 20;


所以我们什么时候应该使用;当我们使用时,
Any statements like
printf("abc");
scanf("%d",&x);
a=20;
can be replaced by
printf("abc"), scanf("%d",&x), a=20;

So when should we use ; and when sould we use ,



如果有疑问,请使用分号。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。

If in doubt, use a semicolon.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


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

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