-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.cpp
41 lines (35 loc) · 864 Bytes
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//============================================================================
// Name : Main.cpp
// Author : An Nguyen
// Description : Main function of the program
//============================================================================
#include <fstream>
#include "Infix_Evaluator.h"
int main()
{
Infix_Evaluator InflixEvaluator;
std::string expression;
std::string answer;
// Input/output files
std::ifstream fin("input.txt");
// Throw error if can't open input file
if(!fin)
{
std::cerr << "Error opening input file!";
system("pause");
return 1;
}
while(fin.good())
{
getline(fin,expression);
answer = InflixEvaluator.evaluate(expression);
if (answer != "null"){
std::cout << "Answer = " << answer ;
}
std::cout << std::endl << std::endl;
}
system("pause");
// Close files
fin.close();
return 0;
}