396
技術社區[雲棲]
計算unsigned short*字符串長度
函數實現:/*
*函 數 名:wuslen
*功 能:計算unsigned short*字符串長度
*輸入參數:str unsigned short*字符串
*輸出參數:無
*返 回 值:unsigned short*字符串
*/
int wuslen(const unsigned short* str)
{
int i=0;
if(str == NULL)
return i;
while(str[i])
{
i++;
}
return i;
}
實例:
#include <stdio.h>
int wuslen(const unsigned short* str)
{
int i=0;
if(str == NULL)
return i;
while(str[i])
{
i++;
}
return i;
}
int main()
{
unsigned short str[] ={0x01,0x02,0x03,0x00};
int len = wuslen(str);
printf("len:%d\n",len);
return 0;
}
最後更新:2017-04-02 06:52:03