Reversing a folder path in a string

Discussion in 'C++' started by Lindsay, Jul 17, 2005.

  1. Lindsay

    Lindsay Guest

    How is this done?

    For example:

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

    Some pointers please?
     
    Lindsay, Jul 17, 2005
    #1
    1. Advertising

  2. 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
     
    Victor Bazarov, Jul 17, 2005
    #2
    1. Advertising

  3. Lindsay

    leonardo77 Guest

    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.
     
    leonardo77, Jul 17, 2005
    #3
  4. Lindsay

    upashu2 Guest

    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\........
     
    upashu2, Jul 18, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. netforce

    reversing a string - newbie question

    netforce, Mar 2, 2004, in forum: C Programming
    Replies:
    9
    Views:
    544
    Old Wolf
    Mar 8, 2004
  2. Albert

    String reversing problem

    Albert, Dec 30, 2005, in forum: C Programming
    Replies:
    46
    Views:
    987
  3. Kelly B

    Reversing order of words in a given string

    Kelly B, Apr 26, 2007, in forum: C Programming
    Replies:
    2
    Views:
    365
    Kelly B
    Apr 26, 2007
  4. Scott

    Reversing a string

    Scott, Jun 27, 2007, in forum: Python
    Replies:
    23
    Views:
    610
    Martin Durkin
    Jul 5, 2007
  5. Rubist Rohit
    Replies:
    19
    Views:
    651
    Adam Prescott
    Apr 23, 2011
Loading...

Share This Page