Squeeze all multiple spaces in a string into one space

#include <stdio.h>  
  
void trimspace(char \*dst) {  
  
    const char \*src = dst;  
  
    int tocopy = 1;  
  
    char c;  
  
    while((c = \*src++)) {  
  
        if(tocopy)  
            \*dst++ = c;  
  
        tocopy = (c != ' ') || (\*src != ' ');  
    }  
  
    \*dst = '\\0';  
}  
  
  
int main() {  
    char s\[64\];  
  
    scanf("%\[^\\n\]c", s);  
  
    trimspace(s);  
  
    printf("%s\\n", s);  
}  


See also