万恶的逗号

想实现的效果如下:

1234567

1,234,567

 

难为死我了~~~~

 

void FormatNumber(PTCHAR pszNum) { TCHAR szTmp[30] = {0}, szRev[30] = {0}; int iLen = lstrlen(pszNum), i, j, k; PTCHAR pos; TCHAR szArry[5][4] = {0,0}; if (iLen <= 3) return; for (i = 0; i < iLen; i++) { szRev[i] = pszNum[iLen - i - 1]; } pos = &szRev[0]; k = 0; for (i = 0; i < 5; i++) { for (j = 0; j < 3; j ++) { szArry[i][j] = pos[k++]; if (pos[k] == _T('/0')) goto __FINISH; } } __FINISH: for (i = 0; szArry[i][0]; i++) { lstrcat(szTmp, szArry[i]); lstrcat(szTmp, _T(",")); } iLen = lstrlen(szTmp) - 1; for (i = 0; i <= iLen; i++) { szRev[i] = szTmp[iLen - i - 1]; } lstrcpy(pszNum, szRev); return; } 

你可能感兴趣的:(万恶的逗号)