Sign in to follow this  

deprecated

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

This topic is 4163 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this