diff --git a/src/userinput.c b/src/userinput.c index bd343e9..e161a63 100644 --- a/src/userinput.c +++ b/src/userinput.c @@ -12,4 +12,13 @@ void trimLeft(char *input) { for (int i = 0; i <= length - firstIndex; i++) { input[i] = input[firstIndex + i]; } +} + +void trimRight(char *input) { + size_t length = strlen(input); + int index = length - 1; + while (index >= 0 && isspace(input[index])) { + input[index] = '\0'; + index--; + } } \ No newline at end of file