Jump to content
  • Advertisement
Sign in to follow this  
Masmo

STL

This topic is 4514 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!