diff options
| author | Carlos Maiolino <[email protected]> | 2025-09-06 09:26:21 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-09-06 09:26:21 +0200 |
| commit | 973e27b243ea7f12b6743894465c67a4a6a87eb2 (patch) | |
| tree | 006a2d9fc8f86b4914499302325fbcaa3941e17c /C/HF/categorize.c | |
| parent | 736967952470e740781c95cf5afb7e705ec59030 (diff) | |
Move some other code here
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'C/HF/categorize.c')
| -rw-r--r-- | C/HF/categorize.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/C/HF/categorize.c b/C/HF/categorize.c new file mode 100644 index 0000000..a455224 --- /dev/null +++ b/C/HF/categorize.c @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void +usage(char *program) +{ + printf("Usage:\n"); + printf("\t%s: <filter1> <output_file_1> <filter2> <output_file_2> <everything>\n", + program); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + char line[80]; + FILE *in; + FILE *file1; + FILE *file2; + FILE *file3; + + if (argc != 6) + usage(argv[0]); + + in = fopen("spooky.csv", "r"); + file1 = fopen(argv[2], "w"); + file2 = fopen(argv[4], "w"); + file3 = fopen(argv[5], "w"); + + while (fscanf(in, "%79[^\n]\n", line) == 1) { + if (strstr(line, argv[1])) + fprintf(file1, "%s\n", line); + else if (strstr(line, argv[3])) + fprintf(file2, "%s\n", line); + else + fprintf(file3, "%s\n", line); + } + + fclose(in); + fclose(file1); + fclose(file2); + fclose(file3); + return 0; +} |
