Jump to content
  • Advertisement
Sign in to follow this  
stenny

deprecated

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

Hello, Whenever I use strcpy, a warning is shown strcpy is deprecated. So, which function should I use then (as vor vsprintf)? -Stenny

Share this post


Link to post
Share on other sites
Advertisement
I'd just go with std::string. You can do 'easy' string formatting with that and when you need it to be an 'old-C' pointer to a character array you can use its c_str() method.

Share this post


Link to post
Share on other sites
VC++ 2k5 ships with safe versions of these C stdlib functions. Either use those or get rid of C runtime functions altogether if you use C++.

Share this post


Link to post
Share on other sites
Instead of strcpy_s, it may be even better to use StringCchCopy(), along with the rest of the string functions from strsafe.h.

Here's a page about all the string manipulation functions you can use from strsafe.h. It lists the functions you should not be using (like strcpy() and vsprintf()), and what you should be using instead of each one (like StringCchCopy() and StringCchVPrintf())
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/strings/usingstrsafefunctions.asp

I guess it's better to use the functions that have Cch (character count) in their name instead of their Cb (byte count) counter-parts, but I'm not 100% sure on that.

And yeah, the best option of all is to use std::string.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!