Skip to content

Instantly share code, notes, and snippets.

@sirupsen
Created January 22, 2010 08:03
Show Gist options
  • Save sirupsen/283580 to your computer and use it in GitHub Desktop.
Save sirupsen/283580 to your computer and use it in GitHub Desktop.
Quine in C.
#include <stdio.h>
main() {
// String to contain program
char *program = "#include <stdio.h>%cmain() {%c char *program = %c%s%c;%c printf(program, 10, 10, 34, program, 34, 10, 10, 10);%c}%c";
/* Insert ascii characters for colon and newline
Write out the program, two new lines, at 34 we start colons
at the program pointer, in the colons write out the program
_again_ stop colons, and paste out some new lines, done! */
printf(program, 10, 10, 34, program, 34, 10, 10, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment