Documentation

BrainF++ documentation

Complete guide to programming in BrainF++ and using the contest platform.

Quick reference
Essential BrainF++ commands
>
Move pointer right
>>
<
Move pointer left
<<
+
Increment cell
++++
-
Decrement cell
----
.
Output character
.
,
Input character
,
[
Start loop
[
]
End loop
]
;
Return value from function
;
{
Start function declaration
{mn
}
End function declaration
}
(
Start function call
(ab
)
End function call
)
Functions
BrainF++ function system

Function declaration

Functions are declared with curly braces. The syntax is {ab code here} where the two-letter function name immediately follows the opening brace, followed by the function code, then the closing brace.

{ab+++.}// Function named "ab"

Main function

Execution always begins in the main function {mn code here}. Code outside of any function is ignored and does not execute.

{mn+++.}// Main function - this runs

Function calls

To call a function, use parentheses with the two-letter function name: (ab). The current cell value is passed as input, and the return value replaces the current cell.

{ab+++;}
{mn++(ab).}// Calls function "ab"

Return values

Use the semicolon ; command to return a value from a function. The current cell value is returned and replaces the cell value at the call site.

{ab++++++;}// Returns 6

Complete example

{ab+++;}
{mn++(ab).}// Sets cell to 2, calls ab (adds 3), outputs 5
Common patterns
Useful code snippets and techniques

Set cell to value (e.g., 10)

++++++++++// Adds 10 to current cell

Clear current cell

[-]// Sets current cell to 0

Copy cell value

[>->+>>&lt;&lt;]>>[&lt;&lt;+>>>-]// Copies cell 0 to cell 2