From 442a49ad5a48d417345959b903ae6a6d32d55759 Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Fri, 15 Apr 2022 15:51:30 -0500 Subject: Great C programming fun Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git --- 34_put_together/main.c~ | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 34_put_together/main.c~ (limited to '34_put_together/main.c~') diff --git a/34_put_together/main.c~ b/34_put_together/main.c~ new file mode 100644 index 0000000..4a3ac74 --- /dev/null +++ b/34_put_together/main.c~ @@ -0,0 +1,49 @@ +#include +#include +#include +#include "kv.h" +#include "counts.h" +#include "outname.h" + +counts_t * countFile(const char * filename, kvarray_t * kvPairs) { + FILE *f = fopen(filename, "r"); + if (f == NULL) { + fprintf(stderr, "Could not open file!\n"); + return NULL; + } + + counts_t * c = createCounts(); + + if (fclose(f) != 0) { + fprintf(stderr, "Could not close file!\n"); + return NULL; + } + return c; +} + +int main(int argc, char ** argv) { + //WRITE ME (plus add appropriate error checking!) + //read the key/value pairs from the file named by argv[1] (call the result kv) + + //count from 2 to argc (call the number you count i) + + //count the values that appear in the file named by argv[i], using kv as the key/value pair + // (call this result c) + + //compute the output file name from argv[i] (call this outName) + + + //open the file named by outName (call that f) + + //print the counts from c into the FILE f + + //close f + + //free the memory for outName and c + + + + //free the memory for kv + + return EXIT_SUCCESS; +} -- cgit v1.2.3