#include <stdio.h>
#include <string.h>
void ltrim(char *s) {
char spaces[] = "\n\t\v\f ";
size_t total_spaces_to_trim = strspn(s, spaces);
if (total_spaces_to_trim > 0) {
size_t len = strlen(s);
if (total_spaces_to_trim == len) {
s[0] = '\0';
}
else {
memmove(s, s + total_spaces_to_trim, len + 1 - total_spaces_to_trim);
}
}
}
int main() {
char s[50] = " c python c++ java php ";
printf("'%s'\n", s);
printf("%i\n", strlen(s));
ltrim(s);
printf("%i\n", strlen(s));
printf("'%s'\n", s);
return 0;
}
/*
run:
' c python c++ java php '
28
24
'c python c++ java php '
*/