#include <string.h>
      #include <ctype.h>
      #include <stdio.h>
      #include <stdlib.h>
      
      char *
      rtrim(char *s) {
      	char *p = s + strlen(s) - 1;
      	while (p >= s && isspace((unsigned char) *p)) {
      		*p = '\0';
      		p--;
      	}
      	return s;
      }
      

      C language logoTrim trailing whitespace

      Codiga's C Recipes

      Whitespace is defined by isspace(). Returns s, modified to be terminated at the start of its trailing whitespace.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.