我需要在 CString::Format 中重复一个字符。 printf 中的类似内容:
printf("%.*s",10, _T("-"));
result: ----------
如何在 CString::Format 中实现这一点?
sOutput.Format(_T("%.*s"),10,_T("-")); //doesn't work
最佳答案
只需使用适当的 CString 构造函数即可。
CString sOutput(_T('-'), 10);
并且如果您必须将它作为某个较大字符串的一部分以 Format
的形式存在,那么它是相同的
CString sOutput;
sOutput.Format(L"Hello %s", CString(_T('-'), 10).GetString());
关于c++ - 如何在 CString::Format 中重复一个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42152523/