lunch-poll-legacy

Lunch Poll Legacy -- poll colleagues where to have lunch
Log | Files | Refs | README | LICENSE

utils.c (357B)


      1 /**
      2  * Lunch Poll Legacy
      3  * Copyright 2024, 2025 Matthias Balk
      4  */
      5 
      6 #include <ctype.h>
      7 #include <string.h>
      8 
      9 
     10 /*
     11  * 'str' will be changed if there are TRAILING whitespaces!
     12  */
     13 char* trim(char *str)
     14 {
     15   while (isspace(*str)) str++;
     16 
     17   char *end = str + strlen(str) - 1;
     18   while (end > str && isspace(*end)) {
     19     *end = '\0';
     20     end--;
     21   }
     22 
     23   return str;
     24 }