• Advertisement
Sign in to follow this  

strsafe.h functions - how to replace??

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

Hey, I have some example code that I'm trying to figure out from MSDN which uses functions from strsafe.h, but my compiler doesn't come with it and I don't particularly want to use the library. How would I replace the functions in it with functions from STL, or how do they work? My program uses StringCchPrintf, StringCchLength, and StringCchCopy, and since I don't know exactly what they do beyond what their namesakes do, don't know how they work, and don't know where to download strsafe.h (I'm using dev-cpp, which doesn't come with it), I'm kind of stuck. Can I get some help, please? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
well yeah, but I'm talking about the functions, not the string class. I don't know what exactly StringCchPrintf, StringCchLength, and StringCchCopy do, and I need to find out.

Share this post


Link to post
Share on other sites
No, it prints to a buffer, as sprintf does.

StringCchPrintf → snprintf
StringCchLength → strnlen
StringCchCopy → strncpy

Share this post


Link to post
Share on other sites
Quote:
Original post by Fruny
No, it prints to a buffer, as sprintf does.

StringCchPrintf → snprintf
StringCchLength → strnlen
StringCchCopy → strncpy


And therefore:

StringCchPrintf → cout.operator<< (and the appropriate stuff)
StringCchLength → (string object).length()
StringCchCopy → string object copy constructor

[smile]

Share this post


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

  • Advertisement