-
-
Save zesterer/fefb15257b41433626572c7e88de0bee to your computer and use it in GitHub Desktop.
Brainfuck Interpreter In C
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
// Run like: ./bf <myfile.bf> | |
#include<stdio.h> | |
main(int u,int**v){char t[1<<12]={0,},c[1<<16];int m=fread(c,1,1<<16,fopen(*++v,"r")); | |
char*p=t,n=0,x=0,*i=c;for(;i-c<m;){ | |
*i==62?p++:*i==60?p--:*i==43?++*p:*i==45?--*p:*i==46?write(1,p,1):*i==44?read(0,p,1):0; | |
if((*i==91&&!*p)||(*i==93&&*p)){*p?n--:n++;for(;n;)*(*p?--i:++i)==91?n++:*i==93?n--:0;*p?0:i--;}i++;}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment