Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

string with api function?

This topic is 2754 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

string fileName;

string filePath;



GetFullPathName(fileName.c_str(),MAX_PATH, ______ ,NULL);




i'm not to familiar with C++ strings and im unsure of how i should have this api function store the C string into a c++ std string. Thanks for any advice!

Share this post


Link to post
Share on other sites
Advertisement
It's easiest to do it something like this, if you know that the max length is MAX_PATH.

char path[MAX_PATH];

GetFullPathNameA(fileName.c_str(), MAX_PATH, path, NULL);

string filePath = path;

Share this post


Link to post
Share on other sites
Sure there is, just no better way. Though that's up to opinion ofc.. This one is certainly short, clear, and since there's only a constant number of bytes needed an array on the stack fits very well.

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!