diff options
Diffstat (limited to 'brainfuck.c')
-rw-r--r-- | brainfuck.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/brainfuck.c b/brainfuck.c index 8e80d07..ceb52c4 100644 --- a/brainfuck.c +++ b/brainfuck.c | |||
@@ -1,5 +1,4 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | ||
3 | #include <string.h> | 2 | #include <string.h> |
4 | 3 | ||
5 | #define MAX_DATA 30000 | 4 | #define MAX_DATA 30000 |
@@ -19,15 +18,12 @@ void init() | |||
19 | memset(&one, 0, sizeof(one)); | 18 | memset(&one, 0, sizeof(one)); |
20 | one.count = 0; | 19 | one.count = 0; |
21 | one.ptr = one.data; | 20 | one.ptr = one.data; |
22 | 21 | ||
23 | while ((c = getchar()) != EOF) | 22 | while ((c = getchar()) != EOF) |
24 | { | 23 | { |
25 | if (c == '\n') | 24 | if (c == '\n') |
26 | break; | 25 | break; |
27 | else | 26 | one.command[++one.count] = c; |
28 | { | ||
29 | one.command[++one.count] = c; | ||
30 | } | ||
31 | } | 27 | } |
32 | one.command[0] = one.count; | 28 | one.command[0] = one.count; |
33 | one.command[one.count] = '\0'; | 29 | one.command[one.count] = '\0'; |
@@ -97,9 +93,7 @@ void run() | |||
97 | 93 | ||
98 | int main(int argc, char **argv) | 94 | int main(int argc, char **argv) |
99 | { | 95 | { |
100 | if (argc > 1) { | 96 | printf("Input the brainfuck expression below\n"); |
101 | freopen(argv[1], "r", stdin); | ||
102 | } | ||
103 | init(); | 97 | init(); |
104 | run(); | 98 | run(); |
105 | return 0; | 99 | return 0; |