s.resize( sprintf( &s[0], "var = %d", a ) );
nice code
took me a while to figure it out
i wanted to use std::string with PathAppend,
here is a definition of PathAppend from msdn:
PathAppend Function
Appends one path to the end of another.
Syntax
BOOL PathAppend(
LPTSTR pszPath,
LPCTSTR pszMore
);
Parameters
pszPath
[in, out] A pointer to a null-terminated string to which the
path specified in pszMore is appended. You should set the size of this
buffer to MAX_PATH to ensure that it is large enough to hold the
returned string.
pszMore
[in] A pointer to a null-terminated string of maximum length
MAX_PATH that contains the path to be appended.
Return Value
Returns TRUE if successful, or FALSE otherwise.
Remarks
This function automatically inserts a backslash between the two
strings, if one is not already present.
The path supplied in pszPath cannot begin with "..\\" or ".\\" to
produce a relative path string. If present, those periods are stripped
from the output string. For example, appending "path3" to "..\\path1\
\path2" results in an output of "\path1\path2\path3" rather than "..
\path1\path2\path3".
so this function appends one string to another, and it expects to find
a trailing zero, unlike sprintf
i know c_str() appends a zero (temporary), and i can use resize to set
string to MAX_PATH, but there's no way afaik to notify it that the
controlled sequence is updated so it should re-read it
so there's no way to avoid that additional buffer