previous | start | next

Filter Program

int main(int argc, char *argv[])
{
  ifstream ifs;
  string good_file;
  string test_file;

  // Usage: filter good_file test_file
  // good_file will be argv[1]
  // test_file will be argv[2]
  good_file = string(argv[1]);
  test_file = string(argv[2]);
    
  vector<int> v = MStd::readInts(good_file);

  ifs.open(test_file.c_str());

  if (!ifs) {
    cout << "Cannot open test file: " << test_file << endl;
    exit(0);
  }
  
  int x;
  int badcnt = 0;
  while( ifs >> x )
  {
    if (MStd::lrank(x, v) == -1 ) {
        badcnt++;
    }
  }
  cout << "There were " << badcnt << " items not in the good list!" << endl;

  return 0;
}


previous | start | next