char *dostring(char *str)
{
char *p=str, *ptr=str,*cur=NULL;
int kol=1;
int f=0;
while(*ptr) //???? ?? ????? ??????
{
if (*ptr && *ptr=='0' && *(ptr+1)=='1') //???? ? ??? ??????????? ???? 01
{
cur=p; //?????????? ??????? ????????? ?????????
*(p++)=*(ptr++);// ?????????? ????
*(p++)=*(ptr++);
kol+=2;//??????????? ??????? ?????????? ??????????? ????????
f=0;
while (*ptr && *ptr=='0' && *(ptr+1)=='1') //???? ? ??? ? ?????? ???? ?? ? ?? ?????????? ???
{
*(p++)=*(ptr++);
*(p++)=*(ptr++);
kol+=2;
f=1;
}
if (!f) //?????????, ???? ???? ???? ?????? ???? ???? ?? ?? ?????????? ????????? ?? ?????????? ?????, ?? ???? ?? ????? cur ? ????????? ???-?? ???????? ??????????
{
p=cur;
kol-=2;
}
if (*p && f) //???? ?? ??? ?? ???????? ?? ?????? ?????? ????? ??????
{
*p=' ';
kol++; //??????????? ???-??
++p;
}
} else ptr++; //???? ??? ?? ???? ?? ?????? ????????? ?? ?????? ??????, ? ???? ??? ?????????? ??????? ??????
}
*p='\0';//????????? ?????? ????-??????
if (*(--p)==' ') //????????? ???? ????????? ?????? ?????? ?????? ?? ??? ?? ???????? ????????
{
*p='\0';
--kol;
}
str=(char*)realloc(str,kol); //??????? ?????????? ????? ??????
return str;//?????????? ????????? ?? ??????
}