15,979
社区成员
发帖
与我相关
我的任务
分享
CString str,str1,str2,str3;
int length_all; //这个是楼主的入参吧,固定的数
int space_length = (length_all - str1.GetLength() - str2.GetLength() - str3.GetLength())/2
str.Empty();
str + str1;
for(int i = 0;i<space_length;i++)
{
str.Append(_T(" "));
}
str + str2;
for(int i = 0;i<space_length;i++)
{
str.Append(_T(" "));
}
str + str3;
CString str, str1=_T("A"), str2=_T("BC"), str3=_T("DEF");
str.Format(_T("%10s %10s %10s"), //右对齐
str1, str2, str3);
TRACE(_T("%s\n"), str);
str.Format(_T("%-10s %-10s %-10s"), //左对齐
str1, str2, str3);
TRACE(_T("%s\n"), str);