-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.c
37 lines (25 loc) · 956 Bytes
/
Main.c
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
#include <iostream>
#include <getopt.h>
#include "Calc.h"
using namespace std;
int main (int argc, char * const * argv) {
char option;
SymTab<Variable>::Set_Debug_Off ();
while ((option = getopt (argc, argv, "x")) != EOF) {
switch (option) {
case 'x': SymTab<Variable>::Set_Debug_On ();
break;
}
}
Calculator calc; // Calculator to use
while (1) {
cout << "\nPlease enter an expression to calculate: ";
if (calc.InToPost () == EOF)
break;
calc.Write_Postfix
(cout << "\nThe expression in postfix order is: ");
cout << "\nwhich evaluates to: " << calc.Eval () << "\n";
cerr << "Calculator is:\n" << calc;
}
cout << "\n";
}