1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <stdio.h> char* s_unique(char* s) { char* p1, *p2; for(p1 = p2 = s; *p1; *p1 = *p2) { if(*p2 != *(p2 + 1)) ++p1; ++p2; } return s; } int main(void) { char s[] = "aaaaaaaaabcccdddddd"; puts( s_unique(s) ); return 0; }
1
abcd