comparison waDs9gmT @ 7595:136a16f35a09

<Moon_> fetch http://pastebin.com/raw/waDs9gmT
author HackBot
date Thu, 28 Apr 2016 22:42:08 +0000
parents
children
comparison
equal deleted inserted replaced
7594:dfbcc47cb2be 7595:136a16f35a09
1 #include <stdio.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5
6
7 // initialize the tape with 30,000 zeroes
8 unsigned long long int tape[30000] = {0};
9 unsigned long long int registrar[3] = {0}; // R1, R2, and R3
10 // set the pointer to point at the left-most cell of the tape
11 unsigned long long int* ptr = tape;
12
13
14
15 void interpret(char* input) {
16 char current_char;
17 size_t i;
18 size_t i2;
19 size_t i3;
20 size_t loop;
21 int i4;
22 time_t t;
23 for (i = 0; input[i] != 0; i++) {
24 current_char = input[i];
25 srand((unsigned) time(&t));
26 i4 = rand() % 7;
27 if (i4 == 0) {
28 ++ptr;
29 } else if (i4 == 1) {
30 --ptr;
31 } else if (i4 == 2) {
32 ++*ptr;
33 } else if (i4 == 3) {
34 --*ptr;
35 } else if (i4 == 4) {
36 putchar(*ptr);
37 } else if (i4 == 5) {
38
39 *ptr = getchar();
40
41 } else if (i4 == 6) {
42 continue;
43 }
44 // More commands to come, the CIOL specs are not done
45 }
46 }
47
48
49 int main( int argc, char *argv[] ) {
50
51 interpret(argv[1]); // outputs input
52 return 0;
53 }