求助如何在vc中强制输出固定长度字符?大哥们看看吧。。。真不会。。
sprintf(m_szBuff, "%6s %1s",item_no,item_name);这段中的item_name有时候会很长,造成打印区域过大,如何强制固定一个item_name的打印字符长度?整个类如下:
void CSaleImpl::PrintBillItem(CString item_no,CString item_name,double qty,double amnt)
{
int nMaxLen = GetSalePos()->GetParams()->m_nMaxPrintLineLen;
int i = 0;
if ( nMaxLen < 32 )
nMaxLen = 32;
CPrinter *printer = GetSalePos()->GetPrinter();
char *pt = m_szBuff;
char *tmp=new char[512];
char *result=new char[512];
sprintf(m_szBuff, "%6s %1s",item_no,item_name);
sprintf(tmp, "%7.f %7.02f",qty,amnt);
GetPrintFormatLines(m_szBuff, tmp, result, nMaxLen);
//GetPrintFormatAlignString(m_szBuff,m_szBuff,DT_CENTER);
printer->PrintLine( result );
delete []tmp;delete []result;
}