For parsing, I tend to use strtok(). I've rarely worried about trimming my lines.
p = strtok(str, " ");
while( p != NULL ) {
... do what I need with this white space separated substring ...
p = strtok(NULL, " "); /* get next substring */
}
The first call to strtok() passes the string. The following calls pass a NULL otherwise strtok() reinitializes.
The passed string is modified by strtok() so if you need the original, use a copy of the string.
The separating characters can be anything desired. You can change the separating characters from one call to the next if desired.
But with all things, there are exception situations, so there are also times I've written my own character-by-character scanner that does what I need for that specific job.
And I also work with shell scripts, awk, and Perl creating tools that aid in my work environment.