blob: 4a3ac7443d3b00efbc133e09520286283c952f65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
}
|