/ Published in: C
Expand |
Embed | Plain Text
// Remove multiple space characters in a string. // Ansi string and UTF-8 only! void deblank(char* string) { char* s = string; char* c = string; do { while (*c == ' ') c++; *s++ = *c; if (*c == '\0') break; if (*++c == ' ') { *s++ = ' '; c++; } } while (1); } int main() { char s[] = "abc def ghj klmn."; deblank(s); return 0; }
You need to login to post a comment.
