getPath

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

std::string getPath(std::string & fullpath);

int main(int argc, char **argv)
{
    std::vector<std::string> arglist;

    for(char ** v = argv+1; *v != NULL; ++v) {
        std::cout << *v << std::endl;
        arglist.push_back( getPath(std::string(*v)) );
    }

    std::copy(arglist.begin(), arglist.end(), std::ostream_iterator<std::string>(std::cout, “n”));
    return EXIT_SUCCESS;
}


std::string getPath(std::string & fullpath)
{
    for(std::string::iterator it = fullpath.begin();
        it != fullpath.end();
        ++it)
    {
        if( *it == ‘\’ )
            *it = ‘/’;
    }

    std::string::size_type pos_beg =  fullpath.at(0)    == ‘”‘ ? 1 : 0;
    std::string::size_type pos_end = *fullpath.rbegin() == ‘/’  ? std::string::npos : fullpath.rfind(‘/’)+1;
    
    return fullpath.substr(pos_beg, pos_end);    
}