Re: How printf() works???????
- From: "Robbie Hatley" <lonewolf@xxxxxxxx>
- Date: Fri, 7 Mar 2008 01:10:39 -0800
"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.
--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
www dott well dott com slant user slant lonewolf slant
.
- Follow-Ups:
- Re: How printf() works???????
- From: Richard Heathfield
- Re: How printf() works???????
- From: Nick Keighley
- Re: How printf() works???????
- From: santosh
- Re: How printf() works???????
- References:
- How printf() works???????
- From: sant . tarun
- Re: How printf() works???????
- From: Richard Heathfield
- Re: How printf() works???????
- From: Richard
- How printf() works???????
- Prev by Date: OK folks, corrected
- Next by Date: Re: Variable length arrays
- Previous by thread: Re: How printf() works???????
- Next by thread: Re: How printf() works???????
- Index(es):
Relevant Pages
|