宁夏建设银行网站,端午节网页设计素材,wordpress的论坛主题,福建省建设执业资格管理注册中心网站1.整数指定格式
格式“%03d” #xff0c;如何把其中的03能够指定0-9之间的任何一个数呢#xff1f;
方法1#xff1a;
把“%03d”逐个字符进行展开#xff0c;%03d --%% 0 %d d
然后整体当作格式使用#xff0c; 举例: int aa 2;int nDotNum 3;CString ss1;CStr…1.整数指定格式
格式“%03d” 如何把其中的03能够指定0-9之间的任何一个数呢
方法1
把“%03d”逐个字符进行展开%03d --%% 0 %d d
然后整体当作格式使用 举例: int aa 2;int nDotNum 3;CString ss1;CString ss2;//ss2.format(L%03d, aa);//%03d --%% 0 %d dss1.Format(L%%0%dd, nDotNum);ss2.Format(ss1, aa);
方法2用*代替整数整体一句话就解决
“ %03d -- %*d 举例 int aa 2;int nDotNum 3;CString ss1;CString ss2;//%03d --%*dss2.Format(L%0*d, nDotNum, aa);
2.float
%.3f --%% . %d f
%.3f --%.* f 举例 float bb 1.123456;int nDotNum 3;CString ss1;CString ss2;//%.3f --%% . %d fss1.Format(L%%.%df, nDotNum);ss2.Format(ss1, bb);//%.3f --%.* fss2.Format(L%.*f, nDotNum, bb);
3.double
%.3lf --%% . %d lf
%.3lf --%.* lf 举例 double cc 2.987654;int nDotNum 3;CString ss1;CString ss2;//%.3lf --%% . %d lfss1.Format(L%%.%dlf, nDotNum);ss2.Format(ss1, cc);//%.3lf --%.* lfss2.Format(L%.*lf, nDotNum, cc);