strsafe.h functions - how to replace??

Started by
5 comments, last by Zahlman 19 years ago
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.
my siteGenius is 1% inspiration and 99% perspiration
Advertisement
Use a C++ std::string object?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
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.
my siteGenius is 1% inspiration and 99% perspiration
Google knew
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
so it just outputs to a console? I had already seen that page, I'm just trying to figure out what the function does that is visibly different from printf, if anything.
my siteGenius is 1% inspiration and 99% perspiration
No, it prints to a buffer, as sprintf does.

StringCchPrintf → snprintf
StringCchLength → strnlen
StringCchCopy → strncpy
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
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]

This topic is closed to new replies.

Advertisement