将long数据存到字符串中并格式化字符串数组

来源:互联网 发布:加里波利战役数据 编辑:程序博客网 时间:2024/06/05 10:18


//将long数据存到字符串中并格式化字符串数组

PTSTR BigNumToString(LONG lNum, PTSTR szBuf, DWORD chBufSize) {

   TCHAR szNum[100];

   StringCchPrintf(szNum, _countof(szNum), TEXT("%d"), lNum);

  //This structure contains information that defines the format of a number string. 

  //The GetNumberFormat function uses this information to customize a number          //string for a specified locale.

   NUMBERFMT nf;
   nf.NumDigits = 0;
   nf.LeadingZero = FALSE;
   nf.Grouping = 3;
   nf.lpDecimalSep = TEXT(".");
   nf.lpThousandSep = TEXT(",");
   nf.NegativeOrder = 0;
   GetNumberFormat(LOCALE_USER_DEFAULT, 0, szNum, &nf, szBuf, chBufSize);
   return(szBuf);
}
原创粉丝点击