From 7e753549ed366b65d42ad6a90a78a8e389170a9e Mon Sep 17 00:00:00 2001 From: Divye Date: Mon, 29 Sep 2014 16:52:03 +0000 Subject: [PATCH] Fixes #4, #5, #6. mm.c fork, parent call and print results of median, child call and print results of mean(). --- mm.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/mm.c b/mm.c index 34e38d8..f993bb1 100644 --- a/mm.c +++ b/mm.c @@ -1,6 +1,6 @@ #include #include - +#include #define debug 0 // Comparison function for qsort() @@ -58,10 +58,31 @@ int main(int argc, char *argv[]) { for (i = 0; i < length; i++) { pt[i] = (int) strtol(argv[i+1], NULL, 10); } + qsort(pt, length, sizeof(int), numcmp); - int value = mean(length, pt); - fprintf(stdout, "\nThe mean of the numbers is %d.\nThis completes the task #2 of the assignment.\n", value ); - int medianValue = median(length, pt); - fprintf(stdout, "\nThe median of the numbers is %d.\nThis completes the task #3 of the assignment.\n", medianValue); + // Print out numbers + fprintf(stdout, "%s: Sorted output is: \n", argv[0]); + for (i=0; i