Re: How printf() works???????
- From: santosh <santosh.k83@xxxxxxxxx>
- Date: Fri, 07 Mar 2008 14:51:55 +0530
Robbie Hatley wrote:
"Richard" <devr_@xxxxxxxxx> wrote:
Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes:
sant.tarun@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.
The expression x < 30 will evaluate to 1 if x is less than 30 and zero
otherwise. Richard said the reverse, by mistake I'm sure.
.
- Follow-Ups:
- Re: How printf() works???????
- From: Richard
- Re: How printf() works???????
- From: Antoninus Twink
- Re: How printf() works???????
- From: Kenny McCormack
- Re: How printf() works???????
- From: Robbie Hatley
- Re: How printf() works???????
- 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: Variable length arrays
- Next by Date: Re: Very strange command-line argument handling of /?
- Previous by thread: Re: How printf() works???????
- Next by thread: Re: How printf() works???????
- Index(es):
Relevant Pages
|