[ create a new paste ] login | about

Link: http://codepad.org/O6Yz1ydr    [ raw code | output | fork ]

C, pasted on Aug 31:
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;
}


Output:
1
abcd


Create a new paste based on this one


Comments: