aboutsummaryrefslogtreecommitdiffstats
path: root/P1
diff options
context:
space:
mode:
Diffstat (limited to 'P1')
-rw-r--r--P1/src/reducer.c6
1 files changed, 3 insertions, 3 deletions
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;
}