void CalcNet(unsigned int ipaddr, unsigned int netmask)
{
unsigned int netAddress = ipaddr & netmask;
unsigned int boastAddress = (~netmask) | netAddress;
cout << hex << boastAddress << endl;
cout << hex << netAddress << endl;
}
int main()
{
CalcNet(0xC0A8000A, 0xffffff00);
return 0;
}
输出:
c0a800ff
c0a80000
工作中遇到设置广播地址成功的情况,设备ping得通,但无法使用的情况