Jump to content
  • Advertisement
Sign in to follow this  

StringCchLength, how do you use it?

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

The third parameter is the place in which the string length will be placed. As opposed to strlen, StringCchLength returns an HRESULT which is used for determining if the function succeeded or not. Here is a usage example:

char myString[256];
size_t maximalStringSize = 256;
size_t targetSize;
res = StringCchLength(myString, maximalStringSize, &targetSize);
if (SUCCEEDED(res))
// OK - targetSize now contains the length of the string.
// Error - probably couldn't find /0 in the 256 first bytes of the string

P.S. Next time when asking a question, try giving some more details. This function is not so popular - I didn't know about it until you've asked :-)

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!