Section 1.4
Accepting User Input
Using the final character in Brainfuck, ,
, we can accept user input. ,
stores the ASCII value corresponding to the user’s input into the cell that is currently being pointed to. Note that this means when the user enters a number like 4
, the value being stored in the cell is not 4
but the ASCII value for 4
(which happens to be 52). This also means that Brainfuck can only accept user input one character at a time. If you would like to accept multiple characters of input at any one time, you will need to keep track of the storage and request multiple characters of input yourself.