From 209af5235c9595b18b4ec41b5b317a8a35dfc116 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 5 Oct 2020 22:11:10 -0500 Subject: Maybe #6 is done? --- P1/src/reducer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'P1/src') diff --git a/P1/src/reducer.c b/P1/src/reducer.c index ad29f6f..7c5e8f2 100644 --- a/P1/src/reducer.c +++ b/P1/src/reducer.c @@ -58,7 +58,7 @@ void reduce(char *key) { int count = 0; while(parsedKey != NULL) { - count++; + count += atoi(parsedKey); parsedKey = strtok(NULL, " "); } @@ -77,8 +77,8 @@ void writeFinalDS(int reducerID){ // Shove word and number of occurances in a file named word.txt char filename[BUFFSIZE] = ""; sprintf(filename, "output/ReduceOut/Reduce_%d.txt", reducerID); - FILE* fptr = fopen(filename, "w"); - fprintf(fptr, "%s %d", tempNode -> key, tempNode -> value); + FILE* fptr = fopen(filename, "a"); + fprintf(fptr, "%s %d\n", tempNode -> key, tempNode -> value); fclose(fptr); tempNode = tempNode -> next; } -- cgit v1.2.3