printf()的工作原理??????? [英] How printf() works???????

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

问题描述



您好,


我将非常感谢您对下面给出的代码片段的一些评论

以及对结果的解释这个指定的代码。


int x = 20;


printf("%d%d%d",x< 30 ,x = 40; x 10);

这些代码的输出将是:: 0 40 1


谢谢和问候,

Tarun


Hello,

I would appreciate some comments about the piece of code given below
and explanation about the result of this specified code.

int x = 20;

printf("%d %d %d",x < 30, x = 40; x 10);
The output of these code will be :: 0 40 1

Thanks and Regards,
Tarun

推荐答案

sa ** ******@gmail.com 写道:

我会很感激有关下面给出的代码的一些评论

和有关此指定代码结果的说明。


int x = 20;


printf("%d%d% d,x <30,x = 40; x 10);
I would appreciate some comments about the piece of code given below
and explanation about the result of this specified code.

int x = 20;

printf("%d %d %d",x < 30, x = 40; x 10);



它没有编译。

It doesn''t compile.


这些代码的输出将是:: 0 40 1
The output of these code will be :: 0 40 1



否,见上文。


Uli

No, see above.

Uli

2008年3月6日星期四21:59:49 -0800(太平洋标准时间), sa ****** **@gmail.com 写道:
On Thu, 6 Mar 2008 21:59:49 -0800 (PST), sa********@gmail.com wrote:

>
您好,

我将不胜感激一些评论下面给出的代码片段和关于这个指定代码的结果的解释。

int x = 20;

printf("%d%d% d",x< 30,x = 40; x 10);

这些代码的输出将为:: 0 40 1
>
Hello,

I would appreciate some comments about the piece of code given below
and explanation about the result of this specified code.

int x = 20;

printf("%d %d %d",x < 30, x = 40; x 10);
The output of these code will be :: 0 40 1



代码调用未定义的行为。它修改x并且它不止一次地评估x

,并且除了确定新的

值之外的其他目的。这两种情况都会导致未定义的行为。因此,

取决于您的心态,您收到的任何输出都是正确的或

该程序没有正确的输出。

删除del for email

The code invokes undefined behavior. It modifies x and it evaluates x
more than once and also for a purpose other than determining the new
value. Either condition causes undefined behavior. Therefore,
depending on your frame of mind, any output you receive is correct or
there is no correct output from the program.
Remove del for email


Richard Heathfield< rj*@see.sig.invalidwrites:
Richard Heathfield <rj*@see.sig.invalidwrites:
sa ******** @ gmail.com 说:

>>
您好,

对于下面给出的代码片段以及有关此指定代码的结果的解释,我将不胜感激。

int x = 20;

printf("%d%d%d",x< 30,x = 40; x 10);

输出这些代码将是:: 0 40 1
>>
Hello,

I would appreciate some comments about the piece of code given below
and explanation about the result of this specified code.

int x = 20;

printf("%d %d %d",x < 30, x = 40; x 10);
The output of these code will be :: 0 40 1



好​​吧,它可能是,一旦你包装一个程序并修复语法

错误(分号而不是逗号)。首先,我会解释为什么你可能会得到那个输出,然后我会解释你为什么不这样做。


x< 30是一个关系表达式,所有表达式都有值。

如果它们是假的,则关系表达式的值为0,如果它们是
,则为1。所以x<如果x小于30,则30将评估为0,否则将评估为1



Well, it might be, once you wrap a program around it and fix the syntax
error (a semicolon instead of a comma). First, I''ll explain why you might
get that output, and then I''ll explain why you might not.

x < 30 is a relational expression, and all expressions have values.
Relational expressions have the value 0 if they''re false, and 1 if they''re
true. So x < 30 will evaluate to 0 if x is less than 30, and 1
otherwise.



实际上并非如此。

It won''t actually.


这篇关于printf()的工作原理???????的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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