# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1293874159 21600 # Node ID feead6f508501cfd7b631e53b059f3f6d037797d # Parent cad6633bc1fc46795963039f248395e09991a35d Modified it to read from filename, added Makefile per problem description diff --git a/Makefile b/Makefile 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 diff --git a/main.c++ b/main.c++ --- 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();