diff options
Diffstat (limited to 'ee1301/wk4/hw4_directory/strap012_HW4C.cpp')
-rw-r--r-- | ee1301/wk4/hw4_directory/strap012_HW4C.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ee1301/wk4/hw4_directory/strap012_HW4C.cpp b/ee1301/wk4/hw4_directory/strap012_HW4C.cpp index 17ef381..e6825dc 100644 --- a/ee1301/wk4/hw4_directory/strap012_HW4C.cpp +++ b/ee1301/wk4/hw4_directory/strap012_HW4C.cpp @@ -22,6 +22,12 @@ int main() std::cout << "File read failed!\n"; return -1; } + fout.open("output_files/election_results.txt"); + if (!fout.is_open()) + { + std::cout << "File write failed!\n"; + return -2; + } while (fin >> Char) { if (Char=='A' || Char=='a') { A++; @@ -56,12 +62,6 @@ int main() << "The winner is the letter \"" << winner << "\"!" << std::endl; - - fout.open("output_files/election_results.txt"); - if (!fout.is_open()) { - std::cout << "File write failed!\n"; - return -2; - } fout << "A," << A << std::endl << "E," << E << std::endl << "I," << I << std::endl |