printf self

K*K posted @ Sat, 29 Jul 2006 14:40:00 +0800 in 转帖 with tags c language , 2073 readers
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 i;for(i=0;i");
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 i;for(i=0;i");
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 i;for(i=0;i

Technorati Tags: , , ,

  • No match

Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter