By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,127 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,127 IT Pros & Developers. It's quick & easy.

Reversing a folder path in a string

P: n/a
How is this done?

For example:

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

Some pointers please?
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Lindsay wrote:
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
Jul 23 '05 #2

P: n/a
Lindsay wrote:
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.

Jul 23 '05 #3

P: n/a
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\........

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.