Hello everyone.
I need help creating a substring function for my string class implementation.
Here is the substring function but it doesn't work.
Could you please tell me what is wrongCode:String String::SubString(int startPosition, int count) { char* sub; if (count == 0) { sub = new char [Length() - startPosition]; for(int i = startPosition; i < Length(); i++) sub[i - startPosition] = Text[i]; } else { sub = new char [count-startPosition]; for(int i = startPosition; i < count; i++) sub[i - startPosition] = Text[i]; sub[count-startPosition]='\0'; } String temp(sub); return temp; }




Reply With Quote
