Re: How printf() works???????
- From: Nick Keighley <nick_keighley_nospam@xxxxxxxxxxx>
- Date: Fri, 7 Mar 2008 01:46:06 -0800 (PST)
On 7 Mar, 09:10, "Robbie Hatley" <lonew...@xxxxxxxx> wrote:
"Richard" <de...@xxxxxxxxx> wrote:
Richard Heathfield <r...@xxxxxxxxxxxxxxx> writes:
sant.ta...@xxxxxxxxx said:
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
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.
How do you figure? It does in standard C. If it doesn't for you,
then your compiler is broken and you should get a better one.
Richard Heathfield made a typo. He meant "So x < 30 will evaluate to
*1* if x
is less than 30, and *0* otherwise."
--
Nick Keighley
.
- References:
- How printf() works???????
- From: sant . tarun
- Re: How printf() works???????
- From: Richard Heathfield
- Re: How printf() works???????
- From: Richard
- Re: How printf() works???????
- From: Robbie Hatley
- How printf() works???????
- Prev by Date: Re: passing invalid datatype
- Next by Date: Re: Assembly in C Standard
- Previous by thread: Re: How printf() works???????
- Next by thread: Re: How printf() works???????
- Index(es):
Relevant Pages
|