输入src 001122334455
输出dest 00:11:22:33:44:44
void string_to_mac_address(char* src,char* dest)
{
size_t len=strlen(src);
const char *s = src;
int num=0;
if (len<12)
return;
if (len)
{
while (len!= 0)
{
if(*s== 'void mac_to_string_address(char* src,char* dest)
{
const char *s = src;
size_t len = strlen(src);
printf("src=%s len=%d\n",src,len);
if (len)
{
while (len!= 0)
{
if(*s==':')
{
s++;
len--;
continue;
}
if(*s== '')
break;
*dest=*s;
s++;
dest++;
len--;
}
*dest = '';
}
}
')
break;
if(num==2)
{
*dest=':';
dest++;
num=0;
continue;
}
*dest=*s;
s++;
dest++;
num++;
len--;
if(len<2)
num=0;
}
*dest = '';
}
}
00:11:22:33:44:55 转为001122334455实现
输入 src 00:11:22:33:44:55
输出 dest 001122334455
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)