Skip to content

Instantly share code, notes, and snippets.

@cablehead
Created February 12, 2013 01:09
Show Gist options
  • Select an option

  • Save cablehead/4759159 to your computer and use it in GitHub Desktop.

Select an option

Save cablehead/4759159 to your computer and use it in GitHub Desktop.
int main() {
int valid = 0;
int invalid = 0;
string line;
string formatted;
PhoneNumberUtil* util = PhoneNumberUtil::GetInstance();
PhoneNumber number;
while (cin) {
getline(cin, line);
if (cin.eof()) break;
if (util->Parse(line, "US", &number) != PhoneNumberUtil::NO_PARSING_ERROR) {
invalid += 1;
continue;
}
if (util->IsValidNumber(number)) {
valid += 1;
cout << line << endl;
} else {
invalid += 1;
}
// util->Format(number, PhoneNumberUtil::INTERNATIONAL, &formatted);
// cout << formatted<< endl;
}
cout << endl;
cout << "Valid: " << valid << endl;
cout << "Invalid: " << invalid << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment