16,473
社区成员
发帖
与我相关
我的任务
分享
CString str = L"192.168.0.221";
int index = 0;
int i = 0;
CString a, b, c, d;
while(str.GetLength() != 0)
{
i = str.Find(L".");
if (i < 0) break;
switch(index)
{
case 0:
{
a = str.Left(i);
break;
}
case 1:
{
b = str.Left(i);
break;
}
case 2:
{
c = str.Left(i);
break;
}
}
str.Delete(0, i + 1);
++index;
}
d = str;
CString str = L"192.168.0.221";
int index = 0;
int i = 0;
CString a, b, c, d;
while(str.GetLength() != 0)
{
i = str.Find(L".");
if (i < 0) break;
switch(index)
{
case 0:
{
a = str.Left(i);
break;
}
case 1:
{
b = str.Left(i);
break;
}
case 2:
{
c = str.Left(i);
break;
}
}
str.Delete(0, i + 1);
++index;
}
d = str;
int a,b,c,d;
sscanf("192.168.0.1", "%d.%d.%d.%d", &a, &b, &c, &d);