-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
70 lines (50 loc) · 1.38 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<unistd.h>
char my_intepreter(FILE* file , char passedIN[])
{
fseek(file,0,SEEK_END);
int source_len=ftell(file);
rewind(file);
char myTape[1000000];
int myPointer = 0;
char buf[100];
char returnArray[100000];
int position = 0;
while( fscanf(file, "%s", buf) != EOF )
{
if(strcmp(buf , "meow") == 0 ){myTape[myPointer]++;}
else if(strcmp(buf , "mEEOw") == 0 )
{
myTape[myPointer] += 5;
}
else if(strcmp(buf , "MEOW") == 0 ){myTape[myPointer]--;}
else if(strcmp(buf , "MeoW") == 0 ){myPointer++;}
else if(strcmp(buf , "left") == 0 ){myPointer--;}
else if(strcmp(buf , "nya") == 0 ){
printf("->%d<-" , myTape[myPointer]);
char c = myTape[myPointer];
passedIN[position] = c;
position++;
}
}
//passedIN = &returnArray[0];
}
int main(int argc,char** argv)
{
FILE* file;
do
{
file = fopen("text.meow","r");
printf("trying to find file\n");
sleep(4);
}while(!file);
char c[10000];
my_intepreter(file , c);
printf("\nFOUND STRING == |%s|" , c);
FILE * sendTO = fopen("pythonMessage.txt", "w");
fprintf(sendTO,"%s",c);
fclose(sendTO);
return 1;
}