Created
May 4, 2011 23:33
-
-
Save mina86/956241 to your computer and use it in GitHub Desktop.
Self printing C program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
const char *fmt = "#include <stdio.h>%c%cint main() {%c const char *fmt = %c%s%c;%c printf(fmt, 10, 10, 10, 34, fmt, 34, 10, 10, 10, 10);%c return 0;%c}%c"; | |
printf(fmt, 10, 10, 10, 34, fmt, 34, 10, 10, 10, 10); | |
return 0; | |
} |
On Thu, 05 May 2011 12:15:45 +0200, OpenGrid wrote:
PHP version: https://gist.github.com/954139
I think this should even work with newlines in the string and single
quote instead of double quotes should save us on dollar, eg:
$s='<%cphp
$s=%c%s%c;
printf($s, 63, 39, $s, 39, 63);
%c>";
Not tested, as I don't have PHP interpreter.
##
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +-----<email/xmpp: [email protected]>-----ooO--(_)--Ooo--
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PHP version: https://gist.github.com/954139