user3184829 user3184829 - 4 months ago 14
Brainfuck Question

"Access is denied" error when running brainfuck interpreter from cmd

This question might be a bit pointless, but I thought it was interesting and I don't know how to find an answer to it otherwise.

I wrote a brainfuck interpreter that takes programs (or file paths) as arguments from the command line; i.e.

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


outputs
@
. Or, it's supposed to, anyway. Actually running this in cmd gives an "Access is denied" error if the argument is not enclosed in double quotes. I assume it has something to do with cmd trying to parse the square brackets; do they have any particular function in cmd?

Answer

Your problem are not square backets. You problem are < and >. They are intended to handle stream redirection, < xxx means get input from xxx, > xxx means send output to xxx

You can enclose the text in double quotes or can escape the "problematic" characters preceding them with a caret

brainfuck ">++++++++[<++++++++>-]<."
brainfuck ^>++++++++[^<++++++++^>-]^<.
Comments