PDA

View Full Version : Post the simplest quine you can think of



epicoder
April 15th, 2010, 04:26 PM
Post the simplest quine you can think of in any language EXCEPT HQ9+.

A quine is a program that prints its own source code.

sh:

#This is a quine in sh.
cat $0

Yeah, yeah, I'm cheating. :roll:

And a simpler one: (also cheap)


#!/bin/cat

Sporkman
April 15th, 2010, 05:07 PM
That's pretty hard.

Barrucadu
April 15th, 2010, 05:10 PM
The null program. Ok, so it's cheating. Oh well :P

Bachstelze
April 15th, 2010, 05:12 PM
sh:

#This is a quine in sh.
cat $0

Only works if the script doesn't have spaces in its filename.

Simon17
April 15th, 2010, 05:16 PM
Here's one in C:

FuturePilot
April 15th, 2010, 05:40 PM
Here's one in C:





Looks more like ninja.

Objekt
April 15th, 2010, 07:57 PM
Programming hurts my head.

Random_Dude
April 15th, 2010, 08:06 PM
Here's one in C:





Well, that's it. Somebody close the thread.:lolflag:

DoktorSeven
April 15th, 2010, 08:07 PM
CBM BASIC:


10 LIST

(Edit: Apparently this board software doesn't like all caps posting, even when appropriate. :) )

Simian Man
April 15th, 2010, 08:11 PM
Here's one in C:







[ian@sanpedro ~]$ cat temp.c
[ian@sanpedro ~]$ gcc temp.c
/usr/lib/gcc/i686-redhat-linux/4.4.3/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
[ian@sanpedro ~]$


Nope. In some languages yes, but not in C.

Simon17
April 15th, 2010, 08:21 PM
Nope. In some languages yes, but not in C.

There's a special compiler trick you need to get it to work, but I don't remember what it is right now.

Simian Man
April 15th, 2010, 08:24 PM
There's a special compiler trick you need to get it to work, but I don't remember what it is right now.

There's no way to compile a program without a main function in standard C. You might be able to compile it into an empty static library, but that doesn't count as a quine because it isn't a program. It is a Python quine though, why not just call it that?

falconindy
April 15th, 2010, 08:31 PM
$ touch quine.c
$ gcc -nostdlib quine.c -o quine
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078
$ ./quine
zsh: segmentation fault: ./quine
I suppose you'd have to declare that stdout contains the source for this to be valid....

MaxIBoy
April 16th, 2010, 12:58 AM
Post the simplest quine you can think of in any language EXCEPT HQ9+.

A quine is a program that prints its own source code.

sh:

#This is a quine in sh.
cat $0That doesn't count.

Here's a real quine (not mine)

b=\' c=\\ a='echo b=$c$b c=$c$c a=$b$a$b; echo $a'
echo b=$c$b c=$c$c a=$b$a$b; echo $a
Source:
http://c2.com/cgi/wiki?QuineProgram

You can easily enough modify this to add stuff which is actually useful.

Frak
April 16th, 2010, 01:19 AM
Here's one in C:




Beat me to it.