Skip to content

Commit

Permalink
FEATURE: successfully extract the data into array row[4]
Browse files Browse the repository at this point in the history
  • Loading branch information
tianhuan committed Sep 22, 2018
1 parent 89f3cf1 commit 465ad9d
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <stdio.h>


/*struct MyTuple {
int address;
int id;
Expand All @@ -10,26 +9,39 @@

int main() {

// void extract_data(int *operation_id, int *timestamp, float *read_timestamp, int *call_id);

const char *read_file = "../read_first_100_lines.out";
FILE *read_single = fopen(read_file, "r");
char *buffer;
int *operation_id = 0, *address = 0, *call_id = 0, times = 0;
FILE *read_single;
char buffer[50];
char row[4][25];
int *operation_id, *address, *call_id, *times;
float *read_timestamp = 0;
char *cursor = "a";


// read the file
read_single = fopen(read_file, "r");
if (read_single == NULL) {
printf("Reading %s failed!", read_file);
exit(2);
}
/* while (EOF != fscanf(read_single, "%d %f %d %d", operation_id, read_timestamp, address, call_id)) {
printf("%d\t%f\t%d\t%d", *operation_id, *read_timestamp, *address, *call_id);
}*/

// char s[50];
for (int i = 0; i < 1 || cursor != NULL; i++) {
cursor = fgets(buffer, 50, read_single);
sscanf(buffer, "[\n]\n", buffer);
sscanf(buffer, "%s %s %s %s", row[0], row[1], row[2], row[3]);
// sprintf(s, "%d\t%f\t%x\t%d\n", row[0], row[1], row[2], row[3]);
// printf(s);
}

fclose(read_single);

printf("Reading %s succeeded!\n", read_file);
return 0;
}

/*
void extract_data(int *operation_id, int *timestamp, float *read_timestamp, int *call_id) {
void extract_data(char buffer[50]) {

}*/
}

0 comments on commit 465ad9d

Please sign in to comment.