Mailing List Archive


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

Re: [tlug] C puzzle



>>>>> "MB" == Masato BITO <masato.bito@example.com> writes:

    MB> At 27 Jul 2002 08:13:41 +0900,
    MB> bruno raoult wrote:
    >> How to get 1? (Ooops. Sorry for this one!)

    MB> main() {
    MB>   int*i, n=20;
    MB>   for(i = 0 ; i < n ; i--)
    MB>     printf("-");
    MB> }

    MB> Is it correct?

I don't think this one satisfies the original request to turn the
sample into a "correct C program". The original code is much more
correct than your solution:)

Nevertheless it works (despite of gcc complaints). I think it's
because the pointer to int is unsigned, so negating it results in a
big positive number.

Correct me if I'm wrong.

Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links