aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinweiClarkChao <[email protected]>2015-01-09 21:49:46 +0800
committerJinweiClarkChao <[email protected]>2015-01-09 21:49:46 +0800
commit6fa3e83d8ab020d5cf8c44cc097d6ac9f79f03fb (patch)
tree71050f920ff0fda3d7d8cedab019214edfda24d1 /brainfuck.c
parent0526e79812cf242e12d5b8f4779f067bd8741668 (diff)
downloadbrainfuck-6fa3e83d8ab020d5cf8c44cc097d6ac9f79f03fb.tar.gz
fix
Diffstat (limited to 'brainfuck.c')
-rw-r--r--brainfuck.c12
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
98int main(int argc, char **argv) 94int 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;
Powered by cgit v1.2.3 (git 2.41.0)