www.monmouth.edu
192.100.64.7
bool found = false;
vector<char *> tkns = split(addr, ".");
if (tkns.size() == 4) {
i = tkns.begin();
while(i != tkns.end()) {
for (nIdx = 0; nIdx < strlen(*i); nIdx++)
if (!isdigit(*i[nIdx]))
goto exit_fun;
i++;
}
found = true;
}
* has lower precedence than [].
*i[nIdx] is *(i[nIdx]).
i[nIdx]?
i[nIdx] is *(i + nIdx).
bool found = false;
vector<char *> tkns = split(addr, ".");
if (tkns.size() == 4) {
vector<char *>::iterator i = tkns.begin();
while (i != tkns.end()) {
char * ep = *i + strlen(*i);
char * cp = find_if(*i, ep, not1(ptr_fun(isdigit)));
if (cp != ep)
goto exit_fun;
i++;
}
found = true;
}
not1() and ptr_fun() are function adapters.
static bool is_number(const char * cp) {
const char * ep = cp + strlen(cp);
const char * fp =
find_if(cp, ep, not1(ptr_fun(isdigit)));
return fp == ep;
}
bool dotted_quad(const string & addr) {
vector<char *> tkns = split(addr, ".");
if (tkns.size() == 4) {
const vector<char *>::iterator e = tkns.end();
const vector<char *>::iterator f =
find_if(tkns.begin(), e, not1(ptr_fun(is_number)));
if (f != e) {
// Found a non number.
}
else {
// They're all numbers.
}
}
}
is_number().
This page last modified on 2 April 2002.