int i=strlen(str)-1;
while(i && isspace(*(str+i))) *(str+(i--))='\0';
while(isspace(*str)) ++str;
return str;

これもそれなりに短い