Skip to content

Instantly share code, notes, and snippets.

@rhaps0dy
Created December 17, 2015 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhaps0dy/d4c95142d5a5dd6bccff to your computer and use it in GitHub Desktop.
Save rhaps0dy/d4c95142d5a5dd6bccff to your computer and use it in GitHub Desktop.
Quine in C
#include<stdio.h>
void f(char*b){while(*b){if(*b=='"'||*b=='\\')putchar('\\');if(*b=='\n') printf("\\n"),b++; else putchar(*b++);}}
void g(char *c){printf("%s", c); putchar('"'); f(c); printf("\");}\n");}
int main(){g("#include<stdio.h>\nvoid f(char*b){while(*b){if(*b=='\"'||*b=='\\\\')putchar('\\\\');if(*b=='\\n') printf(\"\\\\n\"),b++; else putchar(*b++);}}\nvoid g(char *c){printf(\"%s\", c); putchar('\"'); f(c); printf(\"\\\");}\\n\");}\nint main(){g(");}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment