[comp.lang.c] ugly code

booloo@lll-lcc.aRpA (Mark Boolootian) (11/23/87)

------>

I have heard of a little piece of C code that is particularly ugly (read un-
readable) that does nothing more than print "hello world" (or something to that
effect).  The main thing is that the code looks like it wouldn't even compile
let alone actually produce some result.  If anyone has a copy of this program,
I would really appreciate it if they would email it to me.  Thanks and I'll
let you figure out the path cause I've no idea where I am.
mb

stephenk@ntcsd1.UUCP (Stephen Keilholz) (12/10/87)

In article <1311@lll-lcc.aRpA> booloo@lll-lcc.UUCP (Mark Boolootian) writes:
>
>------>
>
>I have heard of a little piece of C code that is particularly ugly (read un-
>readable) that does nothing more than print "hello world" (or something to that
>effect).  The main thing is that the code looks like it wouldn't even compile
>let alone actually produce some result.  If anyone has a copy of this program,
>I would really appreciate it if they would email it to me.  Thanks and I'll
>let you figure out the path cause I've no idea where I am.
>mb

I have never seen one that prints "hello world" that was ugly but the
following example of ugly code was presented for the final exam of a
'C' language course I just completed at North Carolina State University:

main(){printf(&unix["\021%six\010\0"],(unix)["have"]+"fun"-0x60)}

I'm pretty sure that the above is correct but I'm doing it from memory
so take that for what it's worth.

Stephen Keilholz
(New user of the network)

daveb@laidbak.UUCP (Dave Burton) (12/10/87)

In article <1311@lll-lcc.aRpA> booloo@lll-lcc.UUCP (Mark Boolootian) writes:
>
>------>
>
>I have heard of a little piece of C code that is particularly ugly (read un-
>readable) that does nothing more than print "hello world" (or something to that
>effect).  The main thing is that the code looks like it wouldn't even compile
>let alone actually produce some result.  ...

I think the following code will fit the bill.
This code (or something very much like it) was
posted as a winner of the Obfuscated C Contest.

/*WhoSaidCIsAnUglyLangauge?*//*WutDuzzitDo?*/
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hello, world!\n",
'/'/'/'));}read(j,i,p){write((j/p)+p,i---j,i/i);}

Read it and weep.
-- 
--------------------"Well, it looked good when I wrote it"---------------------
 Verbal: Dave Burton                        Net: ...!ihnp4!laidbak!daveb
 V-MAIL: (312) 505-9100 x325            USSnail: 1901 N. Naper Blvd.
#include <disclaimer.h>                          Naperville, IL  60540

ggs@ulysses.homer.nj.att.com (Griff Smith) (12/11/87)

In article <212@ntcsd1.UUCP>, stephenk@ntcsd1.UUCP writes:
> ... the following example of ugly code was presented for the final exam of
> a 'C' language course I just completed at North Carolina State University:
> 
> main(){printf(&unix["\021%six\010\0"],(unix)["have"]+"fun"-0x60)}
> 
> I'm pretty sure that the above is correct but I'm doing it from memory
> so take that for what it's worth.

Close.  It's

main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}

It was written by Dave Korn as an entry in the 1987 International
Obfuscated C Code Contest.  It took the prize as "best one liner".

| Stephen Keilholz
| (New user of the network)

OK, we'll forgive you.  Tell your instructor to credit the author next time.
-- 
Griff Smith	AT&T (Bell Laboratories), Murray Hill
Phone:		1-201-582-7736
UUCP:		{allegra|ihnp4}!ulysses!ggs
Internet:	ggs@ulysses.uucp