I'm trying to make this code recursive but for some reason it doesn't work.
void compress_spaces(char *str)
{
char *dst = str;
for (; *str; ++str) {
*dst++ = *str;
if (isspace(*str)) {
do ++str; while (isspace(*str));
--str;
}
}
*dst = 0;
}
EDIT: I tried this:
void text_r(char *str)
{
char *dst = str;
if(*str=='\0')return ;
*dst++ = *str;
if (isspace(*str)) {
do ++str; while (isspace(*str));
--str;
}//Missing brace from orig is this ok?
return text_r(str++);
}
Didn't work. Any ideas?