Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void strtrim(char *str){
- char *begin = NULL, *end = NULL, *c;
- int at_space_substr = 1;
- for(c = str; *c; c++){
- if((*c == ' ' || *c == '\t') ^ at_space_substr){
- if(!begin)
- begin = c;
- else if(!at_space_substr)
- end = c;
- at_space_substr ^= 1;
- }
- }
- if(!begin)
- goto ret;
- if(!end)
- end = c;
- for(c = begin; c < end; c++, str++)
- *str = *c;
- ret:
- *str = '\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement