ss_string_ltrim(3) - Linux man page
Name
ss_string_trim, ss_string_ltrim, ss_string_rtrim - deletes leadingcharacters
Synopsis
#include <sstrings2.h>Linking with -lsstrings2
int ss_string_trim(ss_string *string, int (*blank)(int));
int ss_string_ltrim(ss_string *string, int (*blank)(int));
int ss_string_rtrim(ss_string *string, int (*blank)(int));
Descripton
ss_string_ltrim deletes all identical leading characters from the left of the string saved in string. The characters are determined by the function pointed to by blank. Note that string must be a valid ss_string object (initialized with ss_string_new).
ss_string_rtrim deletes all identical leading characters from the right of the string saved in string. The characters are determined by the function pointed to by blank. Note that string must be a valid ss_string object (initialized with ss_string_new).
blank returns 1 if the character has to be deleted, 0 otherwise. Please take a look at the example above.
Returning values
The functions return 1 on success, 0 otherwiseError values for ss_errno
SS_NULL is a parameteris NULL
SS_EINVAL if the ss_string objects are invalid
Examples
I want to delete all blank spaces (' ', TAB) and new-lines/carriage-return (\r, \n)#include <sstrings2.h> #include <stdio.h> int space(int c) { switch(c) { case ' ': case '\n': case '\t': case '\r': return 1; } return 0; } int main(void) { ss_string *string; string = ss_string_new(" \t\n Hello, World \n\n"); if(!string) return 1; ss_string_trim(string, space); printf("%s\n", string->str); ss_string_free(string, 1); return 0; }