Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. const String& String::operator-=(const String &S)
  2. {
  3. for(int i=len-S.len;i>0;i--)
  4. {
  5. bool tr=true;
  6. for(int j=i;j<i+S.len;j++)
  7. {
  8. if(str[j]!=S.str[j-i])
  9. tr=false;
  10. }
  11. if(tr)
  12. {
  13. for(int j=0;j<S.len;j++)
  14. str[i+j]=str[i+j+S.len];
  15. len-=S.len;
  16. char *temp=new char[len+1];
  17. strcpy(temp,str);
  18. delete[] str;
  19. str=new char[len+1];
  20. strcpy(str,temp);
  21. delete[]temp;
  22. break;
  23. }
  24. }
  25. return *this;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement