-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdreadtest.cpp
More file actions
47 lines (39 loc) · 940 Bytes
/
dreadtest.cpp
File metadata and controls
47 lines (39 loc) · 940 Bytes
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
#include "dread.h"
#include <cstdlib>
#include <cstdio>
int main(void){
FILE * fp = fopen("init_member", "r");
if(fp){
fseek(fp, 0, SEEK_END);
int size = ftell(fp);
char str[] = ": \n";
char * buffer = (char *)malloc(sizeof(char)*size + 1);
memset(buffer, 0, size + 1);
fseek(fp, 0, SEEK_SET);
fread(buffer, sizeof(char), size, fp);
printf("%s\n", buffer);
char * token;
int o1;
double o2;
double d[3];
token = strtok(buffer, str);
while(1){
if(!strcmp(token, "brain")){
o1 = atoi(strtok(NULL, str));
o2 = atof(strtok(NULL, str));
printf("READ : brain, %d %f\n", o1, o2);
}
if(!strcmp(token, "deal")){
d[0] = atof(strtok(NULL, str));
d[1] = atof(strtok(NULL, str));
d[2] = atof(strtok(NULL, str));
printf("READ : deal, %f %f %f\n", d[0], d[1], d[2]);
}
token = strtok(NULL, str);
if(!token) break;
}
free(buffer);
fclose(fp);
}
return 0;
}