From efceadecd1bc48e2169bdf693058b2be25249827 Mon Sep 17 00:00:00 2001 From: Oskar Date: Wed, 3 Apr 2024 22:22:19 +0200 Subject: new check_length_fix_stdin. It checks length of buffers and seems to also fix the situation where if i input more characters in to fgets than allowed the characters sort of get stuck in stdin and thats a problem. Seems like this function fixes this. --- process_multiples.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'process_multiples.c') diff --git a/process_multiples.c b/process_multiples.c index 0acd82d..5abbdfa 100644 --- a/process_multiples.c +++ b/process_multiples.c @@ -33,9 +33,10 @@ uint64_t call_L_plus_minus_continue(char *multiple) { uint64_t call_L_only(uint64_t focus, uint64_t Flines) { - char buf[32] = { '\0' }; + char buf[33] = { '\0' }; fprintf(stdout, "(L): "); - fgets(buf, 30, stdin); + fgets(buf, 32, stdin); + if(check_length_fix_stdin(buf) == _FAIL) { return _FAIL; } if (buf[0] == '\n') { return focus; -- cgit v1.2.3