changeset 7:feead6f50850

Modified it to read from filename, added Makefile per problem description
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Sat, 01 Jan 2011 03:29:19 -0600
parents cad6633bc1fc
children b2c93de84b36
files Makefile main.c++
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+
+breathalyzer: main.c++ bk-tree.c++ levenshtein.c++
+	g++ -O2 main.c++ -o breathalyzer
\ No newline at end of file
--- a/main.c++
+++ b/main.c++
@@ -9,7 +9,7 @@
   std::transform( str.begin(), str.end(), str.begin(),  &toupper);
 }
 
-int main()
+int main(int argc, char** argv)
 {
   using namespace std;
   bk_tree tree;
@@ -18,9 +18,12 @@
     load_tree(tree,ifs);
   }
 
+  string filename = argv[1];
+  ifstream ifs(filename.c_str());
+
   size_t total_distance = 0;
   string word;
-  while( cin >> word)
+  while( ifs >> word)
   {
     string_to_upper(word);
     size_t m = word.size();