/brainfuck

A brainf*ck interpreter written in C

Primary LanguageC

About

TL;DR: It's just a big one dimension character array where all values are set to 0 and you can control the pointer with its 8 commands. A character holds ASCII values, so by increasing a value one by one(like a caveman) you can get to characters such as 'a', '1', 'space'.

Commands Meaning
, Get user input and store in the pointer
. Print what is in the pointer
+ Increase the char by one
- Decrease the char by one
> Move the pointer to the right
< Move the pointer to the left
[ Start a loop
] End a loop if the pointer is 0, otherwise, go back where [ was and loop again

For more details see.

Some tests I'm using to test my implementation, feel free to use it too.

Warning: it still doesn't support nested loops.

Installing

  1. Compile with:
gcc -o brainfuck brainfuck.c
  1. Create a text file example.txt or with any extension you want
  2. Run:
brainfuck example.txt