From 86676cae61a1e64aca65dc4b186584a89f689948 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Tue, 5 Dec 2023 10:39:57 -0500 Subject: [PATCH] Improve boilerplate. --- boilerplate.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/boilerplate.c b/boilerplate.c index 1e7cafe..61f1715 100644 --- a/boilerplate.c +++ b/boilerplate.c @@ -2,10 +2,14 @@ #include #include +#define DEFAULT_FILE "input.txt" +#define STRBUF_LEN 200 +#define ISDIGIT(X) (X >= '0' && X <= '9') + int main(int argc, char **argv) { - // Get filename as an argument, defaults to "input.txt" - char *path = (argc > 1) ? argv[1] : "input.txt"; + // Get filename as an argument, if there is one + char *path = (argc > 1) ? argv[1] : DEFAULT_FILE; if (!path) { @@ -14,6 +18,7 @@ int main(int argc, char **argv) } FILE *file = fopen(path, "r"); + char strbuf[STRBUF_LEN] = {0}; if (!file) { @@ -21,7 +26,12 @@ int main(int argc, char **argv) return 1; } - // Code goes here + + while (fgets(strbuf, STRBUF_LEN, file)) + { + // Code goes here + + } return 0; } \ No newline at end of file