Exemplo n.º 1
0
int main(int argc, char **argv) {
  if (argc < 2) {
    std::cout << "Useage: 11.33 <dict filename> [<input filename>] "
                 "[<output filename>]" << std::endl;
    return -1;
  }
  std::ifstream in_dict(argv[1]);
  if (!in_dict.is_open()) {
    std::cerr << "Cannot open file: " << argv[1] << std::endl;
    return -2;
  }
  std::ifstream in_text;
  if (argc >= 3) {
    in_text.open(argv[2]);
    if (!in_text.is_open()) {
      std::cerr << "Cannot open file: " << argv[2] << std::endl;
      return -2;
    }
  }
  std::istream &in = (argc >= 3 ? in_text : std::cin);
  std::ofstream out_text;
  if (argc >= 4) {
    out_text.open(argv[3]);
    if (!out_text.is_open()) {
      std::cerr << "Cannot open file: " << argv[3] << std::endl;
      return -2;
    }
  }
  std::ostream &out = (argc >= 4 ? out_text : std::cout);
  word_transform(in_dict, in, out);

  return 0;
}
Exemplo n.º 2
0
int main()
{
	word_transform("rules.txt", "input.txt");
	system("pause");
	return 0;
}