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;

int i,*n=20;

This (on my machine) prints a single '-'. It works because in `i < n'
comparison on the following line int i is promoted to int* (= a large
positive number).

    MB>   for(i = 0 ; i < n ; i--)
    MB>     printf("-");
    MB> }

Hope not everybody is tired of this silliness :)

Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links