void main()
{
int i = 0;
int colon = 0;
char tmp1[512] = {0};
char tmp[512] = {0};
char IP6Address[] = "2001:1::3001";
while(IP6Address[i])
{
printf("IP6Address[%d] = %c \t",i,IP6Address[i]);
if ((IP6Address[i] == ':') && (IP6Address[i-1] != ':'))
{
sprintf(tmp1,"%%.4x");
strcat(tmp,tmp1);
printf("1");
}
i++;
}
printf("tmp = %s \n",tmp);
}
Result:
tmp = %.4x%.4x
Reference:
0 意見:
張貼留言