Fixing the multiple spaces case that are not stripped in the second post...
void strip_extra_spaces(char *str) {
int i, x;
for(i = x = 0; str[i]; ++i) {
if(!isspace(str[x]) && !isspace(str[i]))
str[x++] = str[i];
}
str[x] = '\0';
}