From c460a26850eca5ded047d0eb0d183b861087aa53 Mon Sep 17 00:00:00 2001 From: standenboy Date: Tue, 30 Apr 2024 14:22:45 +0100 Subject: write up update --- comp/lucas-standen-NEA/code/parser/preprocessor.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 comp/lucas-standen-NEA/code/parser/preprocessor.c (limited to 'comp/lucas-standen-NEA/code/parser/preprocessor.c') diff --git a/comp/lucas-standen-NEA/code/parser/preprocessor.c b/comp/lucas-standen-NEA/code/parser/preprocessor.c new file mode 100644 index 0000000..92c6127 --- /dev/null +++ b/comp/lucas-standen-NEA/code/parser/preprocessor.c @@ -0,0 +1,24 @@ +#include +#include + +#include "readfile.h" + +char *preprocessor(int argc, char **argv){ + char *buf = readfile(argv[1]); + if (buf == NULL) + return NULL; + + int i = 0; + + while (buf[i] != '\0'){ + if (buf[i] == '\n'){ + buf[i] = ' '; + } + if (buf[i] == '\t'){ + buf[i] = ' '; + } + i++; + } + + return buf; +} -- cgit v1.2.3