find_last_of

M

Mike

Hi
I need this not only for Win/Lin but also for Mac. So it's fine for /
and \ within paths but how should I add the old : which were used once
for mac paths?
Many thanks
Michael

string Texstr = filepath;
string::size_type n = Texstr.find_last_of("/\\\:");
 
F

Francesco S. Carta

Hi
I need this not only for Win/Lin but also for Mac. So it's fine for /
and \ within paths but how should I add the old : which were used once
for mac paths?
Many thanks
Michael

string Texstr = filepath;
string::size_type n = Texstr.find_last_of("/\\\:");

Listen to your compiler when you'll feed that exact last line of code to
it because of the unknown escape sequence. Anyway, you should be fine
finding the last colon in a string that way. Though, I have no idea of
what old mac paths looked like :)
 
J

Jorgen Grahn

Hi
I need this not only for Win/Lin but also for Mac. So it's fine for /
and \ within paths but how should I add the old : which were used once
for mac paths?
Many thanks
Michael

string Texstr = filepath;
string::size_type n = Texstr.find_last_of("/\\\:");

Why do you escape the ':'? Remove the first two characters, and the
string reads "\:".

Note that I know nothing about what you *really* want to do.
It seems similar to Unix's basename(1), but I don't know what
you want to happen to C:foo or C:\foo, or /usr//bin or /usr/bin////,
or /tmp/: and if you want different answers on different OSes.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top