Skip to content

Instantly share code, notes, and snippets.

@t0mdicks0n
Created October 19, 2018 14:46
Show Gist options
  • Save t0mdicks0n/feac314595d25d78eb5c4f712ef93c6d to your computer and use it in GitHub Desktop.
Save t0mdicks0n/feac314595d25d78eb5c4f712ef93c6d to your computer and use it in GitHub Desktop.
Run with: `gcc -o quine quine.c && ./quine `
#include <stdio.h>
int main()
{
int c;
// Open the source code as a file buffer
FILE* file = fopen("./quine.c", "r");
if (file) {
// Iterate over the characters in the file
while ((c = getc(file)) != EOF)
putchar(c);
// Close the file buffer
fclose(file);
// Print a new line to the console
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment