• Advertisement
Sign in to follow this  

This topic is 4246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am new to this C++ standard library. My task is that i will get the string as argument and i need to append , replace some characters and return that buffer : void ExpandPath(const _TCHAR* lpszPath); ExpandPath("$cas/abc/123") { ============================== ============================== ============================== ============================== I need to return "K:\\cas\\abc\\123" ; and i will replace "$cas" with "K:\\cas" and later append to "/abc/123". and then,i need to replace '/' with '\\' in the character buffer ! } Any help is greatly appreciated. Thanks for your co-operation

Share this post


Link to post
Share on other sites
Advertisement
I believe the following would be a step in the right direction.


using std::string;
string path = lpszPath;
string::size_type start;

while (string::npos != (start = path.find("$cas")) {
path.replace( start, strlen("$cas"), "K:\\cas" );
}

while (string::npos != (start = path.find("/")) {
path.replace( start, 1, "\\" );
}

return path;

Share this post


Link to post
Share on other sites
Thanks alot ! It worked straight away !
Once again very much thank you !

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement