11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 28: Standardizing on the Standard Template Library365// removeSpaces - remove any spaces within a stringstring removeSpaces(string s){// find the offset of the first space;// keep searching the string until no more spaces foundsize_t offset;while((offset = s.find(“ “)) != -1){// remove the space just discovereds.erase(offset, 1);}return s;}// insertPhrase - insert a phrase in the position of// for insertion pointstring insertPhrase(string source){size_t offset = source.find(“”);if (offset != -1){source.erase(offset, 4);source.insert(offset, “Randall”);}return source;}int main(int argc, char* pArgs[]){// create a string that is the sum of two smaller stringscout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!