wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/String/StrFmtLen

Version 2 (modified by Don Wilson, 7 years ago) ( diff )

--

StrFmtLen

Format a string with a format specifier and a variable number of parameters.

string StrFmtLen(int nLen, const char* pszFmt, ...);

Parameters

  • nLen - length to make the generated output string
  • pszFmt - character array of formatting information
  • ... - variable number of parameters to fill in formatting specifiers

Return Value

  • Returns the formatted string

Remarks

This is similar to StrFmt but with the added length parameter. If the output string would be shorter than the specified length the output is padded with spaces to the right to make the string the desired length. If the output string would be longer than the specified length the output is truncated. If string parameters are used the ".c_str()" method will be needed to convert this to C style strings. Refer to http://www.cplusplus.com/reference/clibrary/cstdio/printf/ for formatting specifiers.

Example

int nVal = 123;
string strID = "ABC";

string strMsg;
strMsg = StrFmtLen(40, "Number: %d ID: %s", nVal, strID.c_str());

See Also

Note: See TracWiki for help on using the wiki.