七行プログラミング part3

このエントリーをはてなブックマークに追加
560539
//befungeコンパイラ(要gcc)
#include <stdio.h>
int system(),i;int main(int c,char**v){FILE*f=fopen(*++v,"r"),*g=fopen("!.c","w"
);char s[99],*o[]={"putchar(*p);","*p=getchar();","while(*p){","}","++p;","--p;"
,"++*p;","--*p;"};fputs("#include<stdio.h>\nint main(void){static int b[30000],"
"*p=b;",g);for(;f&&(c=fgetc(f))-EOF;)for(i=8;0<i--;)fputs(".,[]><+-"[i]-c?"":o[i
],g);fputs("return 0;}",g);fclose(f);fclose(g);sprintf(s,"gcc !.c -o%s",*++v);
return system(s);}