Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In C language, how to convert the string "192.168.1.1"into a MAC address or an IP address?
In C language, how to convert the string "192.168.1.1"into a MAC address or an IP address?
//display CString IP address in IPAddressCtrl.

CString strIP = " 192. 168. 1. 1 ";

DWORD dwIP

dwIP = inet _ addr(strIP);

Unsigned character *pIP = (unsigned character *)&; dwIP

m_ipAddr。 SetAddress(*pIP,*(pIP+ 1),*(pIP+2),*(pIP+3));

//get the IP address in IPAddressCtrl and convert it into CString type.

Unsigned character * pIP

CString article;

DWORD dwIP

m_ipAddr。 get address(dwIP);

PIP = (unsigned character *)&; dwIP

Strip. Format ("%u.%u.%u.%u",*(pIP+3), *(pIP+2), *(pIP+ 1), * pip);

You can learn from others' experience.