下邊這段程式碼是計算一個字串的字元個數的,注意不是字串長度,自己改吧,很簡單
int StringCountCharsA(CHAR *szTarget)
{
int nCount = 0,nCorsor = 0;
byte btChar;
btChar = *(byte*)szTarget;
while(0x00 != btChar)
nCount ++;
if(::IsDBCSLeadByte(btChar))
nCorsor += 2;
}else
nCorsor += 1;
}
btChar = *(byte*)(szTarget+nCorsor);
return nCount;
下邊這段程式碼是計算一個字串的字元個數的,注意不是字串長度,自己改吧,很簡單
int StringCountCharsA(CHAR *szTarget)
{
int nCount = 0,nCorsor = 0;
byte btChar;
btChar = *(byte*)szTarget;
while(0x00 != btChar)
{
nCount ++;
if(::IsDBCSLeadByte(btChar))
{
nCorsor += 2;
}else
{
nCorsor += 1;
}
btChar = *(byte*)(szTarget+nCorsor);
}
return nCount;
}