法一
#include <stdio.h>
#include <string>
#include<iostream>
using namespace std;
void IPAddressParse(string &IpAddress, const unsigned int numericIp)
{
string temp;
temp += to_string(numericIp >> 24);
temp += '.';
temp += to_string((numericIp & 0x00ff0000) >> 16);
temp += '.';
temp += to_string((numericIp & 0x0000ff00) >> 8);
temp += '.';
temp += to_string(numericIp & 0x000000ff);
IpAddress = temp;
}
int main()
{
unsigned int startIp = 0xc0a80002;
unsigned int endIp = 0xc0a800fe;
unsigned int i;
for (i = startIp; i <= endIp; i++)
{
string IpAddress;
IPAddressParse(IpAddress, i);
cout << IpAddress << endl;
}
return 0;
}