字符串补齐

来源:互联网 发布:霸主软件官网 编辑:程序博客网 时间:2024/04/28 19:19
CString str ="53 2f 2 3 4 ffffff4f 0 45";CString strTmp1 = "";CString strTmp2 = "";str.Remove('f');for (int i = 0; i <= 9; ++i){strTmp1.Format(" %d ", i);strTmp2.Format(" %.2d ", i);while (str.Find((LPCTSTR)strTmp1) != -1){str.Replace((LPCTSTR)strTmp1, (LPCTSTR)strTmp2);}}cout << (LPCTSTR)str << endl;// 运行结果53 02 02 03 04 04 00 45Press any key to continue
0 0
原创粉丝点击