Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const String& String::operator-=(const String &S)
- {
- for(int i=len-S.len;i>0;i--)
- {
- bool tr=true;
- for(int j=i;j<i+S.len;j++)
- {
- if(str[j]!=S.str[j-i])
- tr=false;
- }
- if(tr)
- {
- for(int j=0;j<S.len;j++)
- str[i+j]=str[i+j+S.len];
- len-=S.len;
- char *temp=new char[len+1];
- strcpy(temp,str);
- delete[] str;
- str=new char[len+1];
- strcpy(str,temp);
- delete[]temp;
- break;
- }
- }
- return *this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement