home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:12310 comp.programming:2308
- Newsgroups: comp.lang.c,comp.programming
- Path: sparky!uunet!munnari.oz.au!metro!mama!andy
- From: andy@research.canon.oz.au (Andy Newman)
- Subject: Re: A LITTLE BRAINTEASER...
- Message-ID: <Bswt31.7zC@research.canon.oz.au>
- Sender: news@research.canon.oz.au
- Organization: Canon Information Systems Research Australia
- References: <aet.713608023@munagin>
- Date: Thu, 13 Aug 1992 06:37:48 GMT
- Lines: 37
-
- aet@mullian.ee.mu.OZ.AU (bert thompson) writes:
- >hi!
- >
- >i have a small problem that's been bugging for a while now.
- >
- >here's a program that reverses input from the keyboard:
- >
- >main()
- > char ch = getchar();
- ^^^^^^^
- NOT AGAIN!
- > if (ch == EOF)
- > ;
- > else {
- > main();
- > putchar(ch);
- > }
- >}
- >
- >the interesting thing about the program is that it uses no data structures
- >(structs, arrays, pointers, etc..), to do its thing. everything is thrown
- >on the stack.
-
- Another interesting thing about this program is that its broken!
-
- So how may machines does this work on? Want to run it on something
- without memory protection and let the little sucker recurse and
- recurse...
-
- If that sounds cryptic remember....
-
- getchar() returns an *int*, you char may not be able to store
- EOF (which is v.often a -ve number).
-
- Should we start a FFP (Frequently Found Problems?)
- --
- Andy Newman (andy@research.canon.oz.au) "int - God's own type"
-