Brainfuck: Why does this happen?

118 Views Asked by At

I have this pretty simple program:

+[----->+++<]>.
+[----->+++<]>.

Trying to log two g's
however the output is
how can i make a newline break the code? operator? Not possible?

2

There are 2 best solutions below

0
Naor Tedgi On

Start your code with > to move to 0 then everything should work

>+[----->+++<]>.
>+[----->+++<]>.

See this thread for forther reading.

https://stackoverflow.com/a/36122876/4267015

0
Keldan Chapman On

Using . does not reset the value at the current cell, which is why you get Ø instead of g as the second char; because you started with a different value. If you want to output gg then the simplest method would be to merely output twice:

+[----->+++<]>.. -> gg

If you want them to be printed on seperate lines, then you just have to output a newline character (ascii value 10) in between:

+[----->+++<]>.  g
>++++++++++.    \n
<.               g

Resulting in:

g
g