Re: is order urgent doubt



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"
.



Relevant Pages

  • Re: is order urgent doubt
    ... i = sizeof(double int); ... and the first code print 4 and the second code print 8. ...
    (comp.lang.c)
  • Re: is order urgent doubt
    ... i = sizeof(long int); ... and the first code print 4 and the second code print 8. ...
    (comp.lang.c)
  • Re: is order urgent doubt
    ... i = sizeof(long int); ... and the first code print 4 and the second code print 8. ...
    (comp.lang.c)
  • is order urgent doubt
    ... i = sizeof(long int); ... and the first code print 4 and the second code print 8. ...
    (comp.lang.c)
  • More about pointer equality
    ... The recent thread on pointer equality leads me to wonder about the following ... int *f ... I think most compilers will make the above code print out "Equal", ... C90 and C99 standards seem to me to require it to print out "Not equal". ...
    (comp.std.c)