Skip to content

Commit d64f1ec

Browse files
committed
Added the dir instructions && other small changes
1 parent 0e114bb commit d64f1ec

File tree

5 files changed

+58
-15
lines changed

5 files changed

+58
-15
lines changed

headers/brainfutils.c

Whitespace-only changes.

headers/brainfutils.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if (item==*"+"){
2+
sprintf(cells[pos], atoi(cells[pos])+1);
3+
}
4+
if (item==*"-"){
5+
sprintf(cells[pos], atoi(cells[pos])-1);
6+
}
7+
if (item==*">"){
8+
pos++;
9+
}
10+
if (item==*"<"){
11+
pos--;
12+
}
13+
if (item==*"."){
14+
printf("%s", cells[pos]);
15+
}
16+
if (item==*","){
17+
}
18+

instructions/en.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
HOW TO BRAINFUCK 101?
2+
3+
Brainfuck is an esoteric language, that is turing-complete and works with cells. It has 8 instructions, and those are:
4+
5+
+ --> Modifies the cell value it is on by 1.
6+
7+
- --> Modifies the cell value it is on by -1.
8+
9+
> --> changes the cell it acts on by 1.
10+
11+
< --> Changes the cell it acts on by -1.
12+
13+
, --> Allows for data input.
14+
15+
. --> Echoes the value of the cell it ends on.
16+
17+
[ --> Starts a loop.
18+
19+
] --> Goes to the las open loop it the cell it ends on does not have the value 0 / null.

instructions/es.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
COMO PROGRAMAR EN BRAINFUCK 101?
2+
3+
Brainfuck es un lenguaje esoterico, el cual es turing completo y funciona con celdas. Tiene 8 instrucciones, las cuales son:
4+
5+
+ --> Modifica el valor de la celda en la que está por 1.
6+
7+
- --> Modifica el valor de la celda en la que está por -1.
8+
9+
> --> Cambia la celda en la que actua por 1.
10+
11+
< --> Cambia la celda en la que actua por -1.
12+
13+
, --> Permite la introducción de datos.
14+
15+
. --> Expulsa el valor de la celda en la que está.
16+
17+
[ --> Comienza un bucle.
18+
19+
] --> Vuelve al último bucle abierto si en la celda en la que acaba no tiene el valor 0 / null.

src/brainfuck.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stdio.h>
22
#include <string.h>
3+
#include "../headers/brainfutils.h"
34

45
/*
56
* How does brainfuck work?
@@ -40,21 +41,7 @@ int main(int argc, char *argv[]){
4041
}
4142

4243
// Read the character and perform an action based on it
43-
if (script[progress]==*"+"){
44-
sprintf(cells[pos], atoi(cells[pos])+1);
45-
}
46-
if (script[progress]==*"-"){
47-
sprintf(cells[pos], atoi(cells[pos])-1);
48-
}
49-
if (script[progress]==*">"){
50-
pos++;
51-
}
52-
if (script[progress]==*"<"){
53-
pos--;
54-
}
55-
if (script[progress]==*"."){
56-
printf("%s", cells[pos]);
57-
}
44+
#include "../headers/brainfutils.h"
5845
progress++;
5946
}while(1);
6047
printf("Error: %s", error);

0 commit comments

Comments
 (0)