printf self
Below C code will print the source code itself.
#include
char buf[100][1000] int cur=-1
void P1(char *p) {sprintf(buf[ cur],p)} //record p to buf
void P2(char *p) { printf(p) putchar(10)} //print p and change line
void P3() {int ifor(i=0i")
P1("char buf[100][1000] int cur=-1")
P1("void P1(char *p) {sprintf(buf[ cur],p)}")
P1("void P2(char *p) { printf(p) putchar(10)}")
P1("void P3() {int ifor(i=0i")
P2("char buf[100][1000] int cur=-1")
P2("void P1(char *p) {sprintf(buf[ cur],p)}")
P2("void P2(char *p) { printf(p) putchar(10)}")
P2("void P3() {int ifor(i=0i
Technorati Tags: freesoftware, language, linux, tips
版权所有丨转载请注明出处:https://kxq.io/archives/printfself