From bb018bf3a2241f36217489e0d9b82d4715ef7b0f Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Mon, 28 Aug 2023 17:44:29 -0400 Subject: swipeGuess: Add ignorechars --- swipeGuess.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'swipeGuess.c') diff --git a/swipeGuess.c b/swipeGuess.c index 41fb29c..44881a7 100644 --- a/swipeGuess.c +++ b/swipeGuess.c @@ -6,6 +6,7 @@ #define BUFSIZE 1024 char wordBuff[BUFSIZE]; char swipeBuff[BUFSIZE]; +bool ignorechars[256] = {false}; // fgets, but without the newline. char *fgetst(char *restrict s, int size, FILE *restrict stream) { @@ -35,7 +36,7 @@ bool swipeCompare(char *swipe, char *word) { bool lastMatch = false; for(swipeP++; swipeP[0]; swipeP++) { lastMatch = false; - while (charcmp(swipeP[0], wordP[0])) { + while (charcmp(swipeP[0], wordP[0]) || ignorechars[wordP[0]]) { wordP++; lastMatch = true; } @@ -70,6 +71,11 @@ int main(int argc, char **argv) { if (argc >= 3) { n = atoi(argv[2]); } + if (argc >= 4) { + for(int i=0; argv[3][i];i++){ + ignorechars[(int)argv[3][0]] = true; + } + } FILE *wordFile = fopen(argv[1], "r"); while (fgetst(swipeBuff, BUFSIZE, stdin)) { query(wordFile, swipeBuff, n); -- cgit 1.4.1