Reversing a folder path in a string

L

Lindsay

How is this done?

For example:

How do I programmatically change "C:\Windows\System32" into
"System32\Windows\C:"?

Some pointers please?
 
V

Victor Bazarov

Lindsay said:
How is this done?

For example:

How do I programmatically change "C:\Windows\System32" into
"System32\Windows\C:"?

Some pointers please?


Split it into strings, put the strings in a list, then print
the list backwards. I am not sure what "pointers" you need.
std::string has 'find', 'substr'. std::list has 'push_back'
and 'rbegin' and 'rend'. Beyond that I would be writing it
for you, and I don't want to.

V
 
L

leonardo77

Lindsay said:
How is this done?
For example:

How do I programmatically change "C:\Windows\System32" into
"System32\Windows\C:"?

Some pointers please?

Tokenize with your favorite tokenizer library(possibly boost's),put the
stuff into your favorite conatiner library(probably STL),then reverse
the container.
 
U

upashu2

Instead of using container/ list, a separate string can also be used,
read the first string "C:\windows\system" and find "\" from reverse
side, then extract substrings, put into another output string as
system\windows\........
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top