用C++实现:判断以字符串形式输入的IP地址是否合法;
**
## IP地址格式:a.b.c.d 其中:0≤a,b,c,d≤255
**
代码片
.
// An highlighted block
#include <iostream>
#include<cstring>
#include<string>
using namespace std;
bool IP(char *ip, char *p1)
{
int s = 0, len = strlen(ip) - strlen(p1);
for(int i = 0; i < len; i++)
{
char p = *(ip + i);
s = int(s * 10 + p - 48);
}
//cout << "s=" << s << endl;
if((len == 0) || (s < 0</