#include <stdio.h>
#include <string.h>
bool compress(char *str)
{
char *p=str,c;
int cnt,i=0;
if(!str)return false;
p = str;
while(*p != '/0'){
cnt = 1;
while(*p == *(p+1)){ cnt++; p++; }
if(cnt != 1){
c = *p;
sprintf(&str[i],"%d",cnt);
i += strlen(&str[i]);
str[i++] = c;
}else str[i++] = *p;
p++;
}
str[i] = '/0';
return true;
}
int main(int argc, char* argv[])
{
char str[64] = "abbcccddddeeeeeeeeeeeeeeeffffffggggggg";
printf("%s/r/n",str);
compress(str);
printf("%s/r/n",str);
return 0;
}