Re: is order urgent doubt
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sat, 31 May 2008 15:30:28 -0700
new to c <non@xxxxxxxxxxxx> writes:
I write the 2 codes
int i;
i = sizeof(long int);
printf("%i", i);
i = sizeof(int long);
printf("%i", i);
and the first code and second code print 4.
Right. It won't necessarily be 4 on all systems, but both are
equivalent.
However, "int long" is very non-idiomatic. The compiler can handle it
with no problem, but human readers are going to stumble over it.
(Please ignore the long flame war that will now begin claiming that
anyone who knows C should be able to read "int long" without any
trouble. The fact that the C standard allows variations in the order
of the keywords is fairly obscure; a member of the standard committee
recently posted here saying he didn't even know about it.)
I write another 2 codes
i = sizeof(double int);
printf("%i", i);
i = sizeof(int double);
printf("%i", i);
and the first code print 4 and the second code print 8.
That's surprising. Your compiler should have rejected it, or at least
warned you about it. Are you sure that's *exactly* what you wrote?
[...]
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: is order urgent doubt
- From: new to c
- Re: is order urgent doubt
- From: Richard Heathfield
- Re: is order urgent doubt
- References:
- is order urgent doubt
- From: new to c
- is order urgent doubt
- Prev by Date: Re: function
- Next by Date: Re: How to send a key event to another process?
- Previous by thread: Re: is order urgent doubt
- Next by thread: Re: is order urgent doubt
- Index(es):
Relevant Pages
|