[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] C (was: QA uploads primer)



Hello,

On Wednesday 17 June 2009, Eduardo M KALINOWSKI wrote:
> On Ter, 16 Jun 2009, Stefanos Harhalakis wrote:
> > [snip]
> > Of course you need to look at the C spec to
> > claim that you understand C in depth (you did... didn't you?) and in
> > order to understand why
> >
> > int n=1; int main() { n=n; printf("%d", n); }
> >
> > will not output '1'
> >
> > [snip]
>
> I couldn't figure why it wouldn't output 1, so I tried (with gcc
> 4.2.3) and it did print "1". :-) Surely it complains about printf not
> being defined previously, but it works and since the parameters happen
> to be correct (even though the compiler does not know that), the
> correct output is printed.
>
> So I'm still curious why you say it would not work. Care to explain?

There was a typo. Instead of:

int n=1; int main() { n=n; printf("%d", n); }

it should be:

int n=1; int main() { int n=n; printf("%d", n); }

Hope this clears things.

As for the "#include <stdio.h>", I intentionally didn't list it. I considered 
it as common-sense.


Reply to: