help with string in array

I have an array with string data in it at myArray[0]. The string is /user/Music/filename.txt what I need is to remove /user/Music/ from it and leave filename.txt in myArray[0]. I just need filename.txt and that's it.

Also this will be used a lot and can't use myArray[0].erase(0,12) because I will have /user/filename.txt as well.

I was thinking about finding the last / and after that should be the filename.txt but don't know how to code that in a loop or something.

1
2
3
4
  MyArray[0].erase(0,12);

// works but sometimes the length I need removed is longer or shorter
// than 12. 
Have you considered locating the last '/' character. If MyArray is an array of string then perhaps std::string.find_last_of() might be appropriate.

OK so how do I code that if my array is myArray[0] and searching for the last / ?
What type of variable is a myArray?
string copyArray[MAX_COPY];

That's the actual one I'm using.
Then I gave you the answer in my first post. Use std::string.find_last_of(). You can find excellent documentation for this function on the internet with just a little searching.

OK thanks I'll look into it.
Cool found what I needed here on this site at http://www.cplusplus.com/reference/string/string/find_last_of/

Thanks I didn't really know what to search for.
Topic archived. No new replies allowed.